com.google.android.material.navigation.NavigationView Java Examples

The following examples show how to use com.google.android.material.navigation.NavigationView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BottomNavigationDialogFragment.java    From ui with Apache License 2.0 7 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final View myView = inflater.inflate(R.layout.fragment_bottomsheet, container, false);
    NavigationView nw = myView.findViewById(R.id.navigation_view);
    nw.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
            mListener.onFragmentPicker(menuItem.getItemId());
            dismiss();
            return false;
        }
    });

    return myView;
}
 
Example #2
Source File: NavigationViewActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Sets checked item on the navigation view. */
public static ViewAction setCheckedItem(final @IdRes int id) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isDisplayed();
    }

    @Override
    public String getDescription() {
      return "Set checked item";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      NavigationView navigationView = (NavigationView) view;
      navigationView.setCheckedItem(id);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example #3
Source File: MainActivity.java    From iBeacon-Android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    Log.i("TimeAttendantFast", "Main Activity Create");
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    TimeAttendantFastFragment fragment = TimeAttendantFastFragment.newInstance();
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.contentFrame, fragment, null).disallowAddToBackStack().commit();
}
 
Example #4
Source File: NavigationDrawer.java    From Open-Source-Android-Weather-App with MIT License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //Suspect 2
        setContentView(R.layout.activity_main);
        //Toolbar toolbar = findViewById(R.id.drawer_layout);
        //Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
        //setSupportActionBar(toolbar);

        DrawerLayout drawer = (DrawerLayout)findViewById(R.id.drawer_layout);
        //ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
//                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();

        //NavigationView navigationView = findViewById(R.id.nav_view);
        NavigationView navigationView = findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
    }
 
Example #5
Source File: MainActivity.java    From android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ButterKnife.bind(this);

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
 
Example #6
Source File: MainActivity.java    From Floating-Navigation-View with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mFloatingNavigationView = (FloatingNavigationView) findViewById(R.id.floating_navigation_view);
    mFloatingNavigationView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mFloatingNavigationView.open();
        }
    });
    mFloatingNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem item) {
            Snackbar.make((View) mFloatingNavigationView.getParent(), item.getTitle() + " Selected!", Snackbar.LENGTH_SHORT).show();
            mFloatingNavigationView.close();
            return true;
        }
    });
}
 
Example #7
Source File: MotionVisualizer.java    From habpanelviewer with GNU General Public License v3.0 6 votes vote down vote up
public MotionVisualizer(SurfaceView motionView, NavigationView navigationView, SharedPreferences preferences, int cameraRotation, int scaledSize) {
    mMotionView = motionView;
    mNavigationView = navigationView;
    mPreferences = preferences;
    mCameraRotation = cameraRotation;

    int newDeviceRotation = ((Activity) mMotionView.getContext()).getWindowManager().getDefaultDisplay().getRotation();
    setDeviceRotation(newDeviceRotation);

    mMotionView.setZOrderOnTop(true);
    mMotionView.getHolder().setFormat(PixelFormat.TRANSPARENT);

    mPaint.setColor(Color.WHITE);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setTextSize(scaledSize);

    Rect bounds = new Rect();
    mPaint.getTextBounds(mNavigationView.getContext().getString(R.string.motion), 0, 6, bounds);
    mMotionTextWidth = bounds.width();

    mPaint.getTextBounds(mNavigationView.getContext().getString(R.string.tooDark), 0, 8, bounds);
    mDarkTextWidth = bounds.width();
}
 
Example #8
Source File: NavigationViewActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Sets item text appearance on the content of the navigation view. */
public static ViewAction setItemTextAppearance(final @StyleRes int resId) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isDisplayed();
    }

    @Override
    public String getDescription() {
      return "Set item text appearance";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      NavigationView navigationView = (NavigationView) view;
      navigationView.setItemTextAppearance(resId);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example #9
Source File: NavigationViewActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Sets item text color on the content of the navigation view. */
public static ViewAction setItemTextColor(final ColorStateList textColor) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isDisplayed();
    }

    @Override
    public String getDescription() {
      return "Set item text color";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      NavigationView navigationView = (NavigationView) view;
      navigationView.setItemTextColor(textColor);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example #10
Source File: NavigationViewActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Sets item background on the content of the navigation view. */
public static ViewAction setItemBackground(final @Nullable Drawable itemBackground) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isDisplayed();
    }

    @Override
    public String getDescription() {
      return "Set item background";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      NavigationView navigationView = (NavigationView) view;
      navigationView.setItemBackground(itemBackground);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example #11
Source File: NavigationViewActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Sets item background on the content of the navigation view. */
public static ViewAction setItemBackgroundResource(final @DrawableRes int resId) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isDisplayed();
    }

    @Override
    public String getDescription() {
      return "Set item background";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      NavigationView navigationView = (NavigationView) view;
      navigationView.setItemBackgroundResource(resId);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example #12
Source File: NavigationViewActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Sets item icon tint list on the content of the navigation view. */
public static ViewAction setItemIconTintList(final @Nullable ColorStateList tint) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isDisplayed();
    }

    @Override
    public String getDescription() {
      return "Set item icon tint list";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      NavigationView navigationView = (NavigationView) view;
      navigationView.setItemIconTintList(tint);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example #13
Source File: NavigationViewActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Removes a previously added header view from the navigation view. */
public static ViewAction removeHeaderView(final @Nullable View headerView) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isDisplayed();
    }

    @Override
    public String getDescription() {
      return "Remove header view";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      NavigationView navigationView = (NavigationView) view;
      navigationView.removeHeaderView(headerView);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example #14
Source File: NavigationViewActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Sets icon for the menu item of the navigation view. */
public static ViewAction setIconForMenuItem(
    final @IdRes int menuItemId, final Drawable iconDrawable) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isDisplayed();
    }

    @Override
    public String getDescription() {
      return "Set menu item icon";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      NavigationView navigationView = (NavigationView) view;
      navigationView.getMenu().findItem(menuItemId).setIcon(iconDrawable);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example #15
Source File: NavigationViewActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/**
 * Removes the specified menu item from the navigation view.
 *
 * @param menuItemId The ID of the menu item to be removed.
 */
public static ViewAction removeMenuItem(final @IdRes int menuItemId) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isAssignableFrom(NavigationView.class);
    }

    @Override
    public String getDescription() {
      return "Remove menu item " + menuItemId;
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();
      NavigationView navigationView = (NavigationView) view;
      navigationView.getMenu().removeItem(menuItemId);
      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example #16
Source File: TestUtilsActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/**
 * Clears and inflates the menu.
 *
 * @param menuResId The menu resource XML to be used.
 */
public static ViewAction reinflateMenu(final @MenuRes int menuResId) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isAssignableFrom(NavigationView.class);
    }

    @Override
    public String getDescription() {
      return "clear and inflate menu " + menuResId;
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();
      final NavigationView nv = (NavigationView) view;
      nv.getMenu().clear();
      nv.inflateMenu(menuResId);
      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example #17
Source File: NavigationViewActivity.java    From android-test with Apache License 2.0 6 votes vote down vote up
private void setupDrawerContent(NavigationView navigationView) {
  navigationView.setNavigationItemSelectedListener(
      new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
          mDrawerLayout.closeDrawer(GravityCompat.START);
          CharSequence menuItemTitle = menuItem.getTitle();
          if (!TextUtils.isEmpty(menuItemTitle)) {
            selectedNavItemTextView.setText(menuItemTitle);
          }
          // Close the navigation drawer when an item is selected.
          menuItem.setChecked(true);
          return true;
        }
      });
}
 
Example #18
Source File: MainActivity.java    From ArcNavigationView with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    NavigationView navigationViewRight = findViewById(R.id.nav_view_right);
    navigationViewRight.setNavigationItemSelectedListener(this);
    navigationView.setNavigationItemSelectedListener(this);
}
 
Example #19
Source File: BaseActivity.java    From privacy-friendly-interval-timer with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if(getSupportActionBar() == null) {
        setSupportActionBar(toolbar);
    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();

    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);

    selectNavigationItem(getNavigationDrawerID());

    View mainContent = findViewById(R.id.main_content);
    if (mainContent != null) {
        mainContent.setAlpha(0);
        mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
    }
}
 
Example #20
Source File: OverScrollDemoActivity.java    From overscroll-decor with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_overscroll_demo);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.recycler_view_demo_title);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.drawer_nav);
    navigationView.setNavigationItemSelectedListener(this);

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.fragment_placeholder, new RecyclerViewDemoFragment())
                .commit();
    }
}
 
Example #21
Source File: MainActivity.java    From busybox with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PrefStore.setLocale(this);
    setContentView(R.layout.activity_main);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    output = findViewById(R.id.outputView);
    scroll = findViewById(R.id.scrollView);

    // enable context clickable
    output.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example #22
Source File: MainActivity.java    From Easer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBackPressed() {
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        getSupportFragmentManager().popBackStack(0, 0); // The -1'st is the Outline. We rely on super.onBackPressed() to pop the 0th.
        NavigationView navigationView = findViewById(R.id.nav_view);
        navigationView.setCheckedItem(R.id.nav_outline);
        super.onBackPressed();
    }
}
 
Example #23
Source File: AdvanceDrawer5Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance5);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    drawer = (AdvanceDrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    drawer.setViewScale(Gravity.START, 0.9f);
    drawer.setRadius(Gravity.START, 35);
    drawer.setViewElevation(Gravity.START, 20);


}
 
Example #24
Source File: AdvanceDrawer2Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance2);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    drawer = (AdvanceDrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    drawer.setViewScale(Gravity.START, 0.9f);
    drawer.setViewElevation(Gravity.START, 20);


}
 
Example #25
Source File: MainActivity.java    From Easy_xkcd with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the listener for the navigationView and adjusts the colors according to our theme
 */
private void setupDrawerContent(NavigationView navigationView) {
    navigationView.setNavigationItemSelectedListener(
            menuItem -> {
                closeDrawer();
                //mDrawer.closeDrawers();
                prepareToolbarAnimation(-300);
                //updateToolbarTitle();
                animateToolbar(-300);
                selectDrawerItem(menuItem, false, false, false, true);
                return false;
            });
    themePrefs.setupNavdrawerColor(navigationView);
}
 
Example #26
Source File: AdvanceDrawer4Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance4);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    drawer = (AdvanceDrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    drawer.setViewScale(Gravity.END, 0.9f);
    drawer.setViewElevation(Gravity.END, 20);


}
 
Example #27
Source File: NavigationViewHelper.java    From candybar with Apache License 2.0 5 votes vote down vote up
public static void initApply(NavigationView navigationView) {
    Context context = ContextHelper.getBaseContext(navigationView);

    MenuItem menuItem = navigationView.getMenu().findItem(R.id.navigation_view_apply);
    if (menuItem == null) return;

    menuItem.setVisible(context.getResources().getBoolean(R.bool.enable_apply));
}
 
Example #28
Source File: AdvanceDrawer3Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance3);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    drawer = (AdvanceDrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    drawer.setViewScale(Gravity.START, 0.9f);
    drawer.setViewElevation(Gravity.START, 20);

    drawer.useCustomBehavior(Gravity.END);

}
 
Example #29
Source File: Advance3DDrawer1Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance_3d_1);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    drawer = (Advance3DDrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    drawer.setViewScale(GravityCompat.START, 0.96f);
    drawer.setRadius(GravityCompat.START, 20);
    drawer.setViewElevation(GravityCompat.START, 8);
    drawer.setViewRotation(GravityCompat.START, 15);



}
 
Example #30
Source File: MainActivityTest.java    From WiFiAnalyzer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testGetNavigationView() {
    // setup
    NavigationMenuController navigationMenuController = mock(NavigationMenuController.class);
    NavigationView navigationView = mock(NavigationView.class);
    when(navigationMenuController.getNavigationView()).thenReturn(navigationView);
    fixture.setNavigationMenuController(navigationMenuController);
    // execute
    NavigationView actual = fixture.getNavigationView();
    // validate
    assertEquals(navigationView, actual);
    verify(navigationMenuController).getNavigationView();
}