daily pastebin goal
84%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <android.support.design.widget.BottomNavigationView
  2.             android:id="@+id/bottom_bar"
  3.             android:layout_width="match_parent"
  4.             android:layout_height="?actionBarSize"
  5.             android:layout_alignParentBottom="true"
  6.             android:layout_gravity="bottom"
  7.             android:background="@color/colorPrimary"
  8.             app:itemIconTint="@drawable/bottom_menu_states_drawable"
  9.             app:itemTextColor="@drawable/bottom_menu_states_drawable"
  10.             app:labelVisibilityMode="labeled"
  11.             app:layout_constraintBottom_toBottomOf="parent"
  12.             app:menu="@menu/bottom_nav_items_menu" />
  13.    
  14. <?xml version="1.0" encoding="utf-8"?>
  15. <menu xmlns:android="http://schemas.android.com/apk/res/android"
  16.     xmlns:app="http://schemas.android.com/apk/res-auto">
  17.  
  18.     <item
  19.         android:id="@+id/menu_explore"
  20.         android:icon="@drawable/ic_discover"
  21.         android:title="@string/explore"
  22.         app:showAsAction="always|withText" />
  23.     <item
  24.         android:id="@+id/menu_categories"
  25.         android:icon="@drawable/ic_categories"
  26.         android:title="@string/categories"
  27.         app:showAsAction="always|withText" />
  28.     <item
  29.         android:id="@+id/menu_cart"
  30.         android:icon="@drawable/ic_cart"
  31.         android:title="@string/cart"
  32.         app:showAsAction="always|withText" />
  33.  
  34.     <item
  35.         android:id="@+id/menu_notifcation"
  36.         android:icon="@drawable/ic_home"
  37.         android:title="@string/notifications"
  38.         app:showAsAction="always|withText" />
  39.     <item
  40.         android:id="@+id/menu_notifcation_2"
  41.         android:icon="@drawable/ic_menu_side"
  42.         android:title="@string/menu"
  43.         app:showAsAction="always|withText" />
  44. </menu>
  45.    
  46. <selector xmlns:android="http://schemas.android.com/apk/res/android">
  47.     <item
  48.         android:state_checked="true"
  49.         android:color="@color/colorAccent" />
  50.     <item
  51.         android:state_checked="false"
  52.         android:color="@color/red_darker" />
  53. </selector>
  54.    
  55. binding.home.bottomBar.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
  56.             @Override
  57.             public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  58.                 //check item title, id or position and make decision accordingly
  59.                 binding.toolbar.title.setText(item.getTitle());
  60.                 return true;
  61.             }
  62.         });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top