0

I'm trying to change the color of the DrawerLayout in my app

<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">

As seen above, I've tried android:background and android:backgroundTint but they both don't seem to be working. Help will be greatly appreciated

Suraj Makhija
  • 1,376
  • 8
  • 16
styles9
  • 23
  • 3
  • 9

3 Answers3

0

Set background color to the second embedded view, e.g. to the ListView in this example:

<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>
Sergio
  • 27,326
  • 8
  • 128
  • 149
0

Instead of changing DrawerLayout background, you should change its child NavigationView or ListView background color.

# If you are using NavigationView inside your DrawerLayout, then just change the background of NavigationView.

<android.support.design.widget.NavigationView
    ................
    ....................
    android:background="#FFFFFF" />

# If you are using ListView inside your DrawerLayout, then just change the background of ListView.

<ListView
    ................
    ....................
    android:background="#FFFFFF" />

Hope this will help~

Ferdous Ahamed
  • 21,438
  • 5
  • 52
  • 61
0

I want to set the background of listview under drawerlayout so i had to do this..

mDrawerList.setBackgroundResource(int);
Makvin
  • 3,475
  • 27
  • 26