简体   繁体   English

导航抽屉颜色

[英]Navigation Drawer color

So, newbie here starting app development. 因此,新手在这里开始应用程序开发。 I created an app with a Navigation Drawer with several fragments. 我用一个带有多个片段的导航抽屉创建了一个应用程序。

The NavDraw has a black background and I want the selected fragment to have a red background (to indicate what fragment is being shown). NavDraw具有黑色背景,我希望所选片段具有红色背景(以指示正在显示的片段)。 Right now, it doesn't give me any visual feedback of the fragment selected, the only feedback I have is when I touch the item in the nav drawer. 目前,它并没有给我有关所选片段的任何视觉反馈,我仅有的反馈是当我触摸导航抽屉中的项目时。

In the layout folder I have the activity_main.xml and several fragments ( fragment_one.xml , fragment_two.xml etc). 在布局文件夹中,我有activity_main.xml和几个片段( fragment_one.xmlfragment_two.xml等)。 I guess the changes I need are going to be implemented in the activity_main, no? 我猜我需要的更改将在activity_main中实现,不是吗?

Any suggestions? 有什么建议么?

Just add the folowing to your ListView: 只需将以下内容添加到您的ListView中:

android:listSelector="#FF0000"

So it will look like the following: 因此,它将类似于以下内容:

<ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:listSelector="#FF0000"
        android:background="@android:color/white" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM