Android - Navigation View item menu background color

后端 未结 5 483
旧巷少年郎
旧巷少年郎 2020-11-29 06:48

i try to change color of my item Navigation View menu :

styles.xml

@drawable/activated_back         


        
5条回答
  •  执笔经年
    2020-11-29 07:16

    You don't set the drawable for the background of a Navigation View item in your styles.xml file. Open up your XML layout file containing your Navigation View widget, and add the following line to the widget's attributes:

    app:itemBackground="@drawable/activated_background.xml"
    

    If you're having trouble with the "app" pointer, add the following line in as well:

    xmlns:app="http://schemas.android.com/apk/res-auto"
    

    Note that this only changes the colour of the background of a selected list item. If you'd like the icon and text colour to change as well, use the app:itemTextColor attribute instead.

提交回复
热议问题