简体   繁体   中英

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). 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). I guess the changes I need are going to be implemented in the activity_main, no?

Any suggestions?

Just add the folowing to your 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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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