[英]Change NavigationView divider color and sub header text color
I im using the android studio navigationview. 我正在使用android studio navigationview。
But i change the navigationview color background to black, 但是我将Navigationview的颜色背景更改为黑色,
and the divider for subheader gone(because the divider is also black). 并且子标题的分隔符消失了(因为分隔符也是黑色的)。
Also the subheader title is gone. 子标题标题也消失了。
Is there a way to change those properties to white or any color? 有没有办法将这些属性更改为白色或任何颜色?
Here is my XML for my menu. 这是菜单的XML。
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group
android:id="@+id/nav_header"
android:checkableBehavior="single">
<item
android:id="@+id/nav_home"
android:checked="true"
android:icon="@drawable/ic_home_black_24dp"
android:title="Home" />
<item
android:id="@+id/nav_search"
android:icon="@drawable/ic_search_black"
android:title="Search Location" />
<item
android:id="@+id/nav_fav"
android:icon="@drawable/ic_favorite"
android:title="Favorites" />
<item
android:id="@+id/nav_recent"
android:icon="@drawable/ic_nav_route"
android:title="Recent Location" />
<item
android:id="@+id/nav_route"
android:icon="@drawable/ic_place"
android:title="Route" />
</group>
<item
android:id="@+id/navigation_subheader"
android:title="Others">
<menu>
<item
android:id="@+id/nav_settings"
android:checkable="true"
android:icon="@drawable/ic_settings"
android:title="Settings" />
<item
android:checkable="true"
android:id="@+id/nav_about"
android:icon="@android:drawable/ic_menu_send"
android:title="About" />
</menu>
</item>
</menu>
Thanks! 谢谢!
For the separator you need to add style to your theme or NavigationView
theme and change the value of android:attr/listDivider
. 对于分隔符,您需要为主题或
NavigationView
主题添加样式,并更改android:attr/listDivider
的值。 Thats the background that divider is using. 多数民众赞成在使用的背景分频器。
Subheader is just a TextView
. 子标题只是一个
TextView
。 When you change the color of the divider you will see that it changes to the subheader. 当您更改分隔符的颜色时,您会看到它更改为子标题。 To change subheader text change the
android:textColorPrimary
and android:textColorSecondary
in v21 value in your style too. 要更改子标题文本,请在您的样式中也更改v21中的
android:textColorPrimary
和android:textColorSecondary
值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.