Question

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?

Was it helpful?

Solution

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" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top