Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 更改抽屉布局的背景色_Android_Android Layout_Android Xml_Android Drawer - Fatal编程技术网

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
抽屉布局内的