2017-04-14 40 views
0
的背景颜色

我想从上面可以看出改变DrawerLayout的颜色在我的应用程序改变DrawerLayout

<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:背景和android:backgroundTint但他们都没有似乎工作。帮助将不胜感激

+0

http://stackoverflow.com的可能重复/ questions/17092687/set-background-color-of-navigation-drawer – Lokesh

+0

将颜色添加到您的listview ...或'NavigationView'内的'DrawerLayout' – rafsanahmad007

回答

0

设置背景颜色到第二个嵌入视图,例如,在这个例子中的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> 
0

而是改变DrawerLayout背景的,你应该改变其子NavigationViewListView背景颜色。

如果您正在使用NavigationViewDrawerLayout内,那么就改变NavigationViewbackground

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

如果您正在使用ListViewDrawerLayout内,那么就改变ListViewbackground

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

希望这将有助于〜

0

我想设置下drawerlayout列表视图的背景,所以我不得不这样做..

mDrawerList.setBackgroundResource(int);