How in style to set the color of the selected item in Drawer? enter image description here

    1 answer 1

    In dravable create selector selector.xml

    <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/press" /> <item android:state_focused="false" android:drawable="@drawable/normal" /> </selector> 

    And two more files press.xml

     <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#FF9D21"/> </shape> 

    and normal.xml

     <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#8BC7EB"/> </shape> 

    Create a style for a drover and override the necessary attributes in it.

      <style name="AppTheme.NavMenu" parent="AppTheme"> <item name="android:textColorPrimary">@color/yourcolor</item> <item name="android:background">@drawable/selector</item> </style> 

    PS: I did not check the code, but the direction of thought is clear :)