我试着寻找通过几个SO回答这个问题,但他们都没有为我工作。不能风格选定抽屉项目的背景颜色
我正在尝试更改我的导航抽屉中选定项目的背景颜色(the gray)。
这里是我的代码:
menu_drawer
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:icon="@drawable/ic_one"
android:id="@+id/nav_first_fragment"
android:title="One"
android:checked="true"/>
<item
android:icon="@drawable/ic_two"
android:id="@+id/nav_second_fragment"
android:title="Two" />
<item
android:icon="@drawable/ic_three"
android:id="@+id/nav_third_fragment"
android:title="Three" />
</group>
</menu>
activity_main
:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
<include
layout="@layout/toolbar"
/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
app:menu="@menu/menu_drawer" />
</android.support.v4.widget.DrawerLayout>
请帮帮忙!
在哪里可以找到导航抽屉使用的各种状态? – user5382818
@ user5382818,检查文档链接 –