Android 更改抽屉布局的背景色
我正在尝试在我的应用程序中更改抽屉布局的颜色Android 更改抽屉布局的背景色,android,android-layout,android-xml,android-drawer,Android,Android Layout,Android Xml,Android Drawer,我正在尝试在我的应用程序中更改抽屉布局的颜色 <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:backgroundTint="#FFFFFF">
如上所述,我尝试了android:background和android:backgroundTint,但它们似乎都不起作用。非常感谢您的帮助为第二个嵌入视图设置背景色,例如本例中的ListView:
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start">
<include
layout="@layout/activity_navigation_app_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ListView android:id="@+id/list_drawer_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:background="#FFFFFF"
android:dividerHeight="0dp"/>
</android.support.v4.widget.DrawerLayout>
您应该更改其子项
导航视图
或列表视图
背景色,而不是更改抽屉布局
背景色
#如果您在抽屉布局中使用导航视图
,则只需更改导航视图
的背景
<android.support.design.widget.NavigationView
................
....................
android:background="#FFFFFF" />
<ListView
................
....................
android:background="#FFFFFF" />
希望这会有所帮助~我想在抽屉布局下设置listview的背景,所以我不得不这样做
mDrawerList.setBackgroundResource(int);
将颜色添加到listview…或navigationView
抽屉布局内的