Good day, Is there a way, displaying colored icons on navigation drawer? Not tinting them or setting them to black, and each of them will have corresponding color (highlight/background) when click, in navigation drawer.
Just like Google Store App drawer.
The overflow background can be changed by defining a popupMenuStyle attribute in the theme. You should extend from Widget. Sherlock. PopupMenu in your own style where you can change the android:background attribute.
com.google.android.material.navigation.NavigationView. Represents a standard navigation menu for application. The menu contents can be populated by a menu resource file. NavigationView is typically placed inside a DrawerLayout .
Yes you can add colored icon using menu group items:
<item
android:id="@+id/drawer_artist"
android:icon="@drawable/artist"
android:title="Artists"/>
And for highlighting the selcted item Use the code below for default selection:
navigationView.getMenu().getItem(0).setChecked(true);
And You can select(highlight) the item by calling
onNavigationItemSelected(navigationView.getMenu().getItem(0));
Edit
If you are using navigationview you can edit option for changing the colortint of icons as follows:
<android.support.design.widget.NavigationView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="@drawable/bg_all"
app:itemIconTint="@android:color/white"
app:itemTextColor="@android:color/white"
app:theme="@style/list_item_appearance"
app:menu="@menu/drawer_menu" >
Edit
If you set navigationView.setItemIconTintList(null);
you will get colored icons.
You can set it in your Activity.Class
navigationView.setItemIconTintList(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With