设置导航抽屉的背景颜色 [英] Set Background Color of Navigation Drawer

查看:95
本文介绍了设置导航抽屉的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Java中设置我的Navigation抽屉的背景颜色,但是它看起来像是setBackgroundColor,所有类似的方法都无效. 仅XML行android:background="@color/mycolor"在起作用.如果删除xml行并尝试其中一种方法,抽屉将保持透明.

I wanted to set the background color of my Navigation drawer in java but it seems as setBackgroundColor and all similar methods have no effect. Only the XML line android:background="@color/mycolor" is working. If remove the xml line and try one of the methods the drawer just stays transparent.

有什么想法吗?

推荐答案

我刚刚解决了自己的问题.

I just solved my own problem.

我完全忘记了它不是要设置背景的DrawerLayout,而是里面的ListView.

I totally forgot that it's not the DrawerLayout I want to set the background to, but the ListView inside.

我承认,如果不在我的帖子中添加代码-.-'

I admit I made it somewhat hard for you guys without adding code to my post -.-'

所以代替:

private DrawerLayout mDrawerLayout;
(...)
mDrawerLayout.setBackgroundResource(int);

我必须这样做:

private ListView mDrawerList;
(...)
mDrawerList.setBackgroundResource(int);

这篇关于设置导航抽屉的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆