java - Navigation drawer item icon not showing original colour -


i'm trying show icon next item within menu navigation drawer, reason icon appears in grey rather original colour (brown). there way of preventing happening in order show icon's original colour?

mainactivity.java

public class mainactivity extends appcompatactivity {      private drawerlayout mdrawerlayout;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          mdrawerlayout = (drawerlayout) findviewbyid(r.id.drawer_layout);          navigationview navigationview = (navigationview) findviewbyid(r.id.nav_view);         if (navigationview != null) {             setupdrawercontent(navigationview);         }     }      private void setupdrawercontent(navigationview navigationview) {         navigationview.setnavigationitemselectedlistener(                 new navigationview.onnavigationitemselectedlistener() {             @override             public boolean onnavigationitemselected(menuitem menuitem) {                 mdrawerlayout.closedrawers();                  return true;             }         });     } } 

drawer_view.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android">     <item android:title="section">         <menu>             <item                 android:id="@+id/navigation_item_1"                 android:icon="@drawable/ic_browncircle"                 android:title="sub item 1" />         </menu>     </item> </menu> 

enter image description here

i found answer here: https://stackoverflow.com/a/30632980/875249

to avoid link pretty straightforward:

    mnavigationview.setitemicontintlist(null); 

this disables state based tinting, can specify own list too. worked great me!

here can details on creating color state list, pretty simple too: http://developer.android.com/reference/android/content/res/colorstatelist.html

    <selector xmlns:android="http://schemas.android.com/apk/res/android">         <item android:state_checked="true" android:color="@color/primary" />         <item android:state_checked="false" android:color="@android:color/white" />     </selector> 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -