Changing Navigation Drawer Selected Item Color from default blue

android

Solution

First, I would try removing the android:listSelector attribute, as I don't believe it is necessary.

Next, I would double check you have all these steps:

- In your application's theme, try adding

themes.xml

<style name="Theme.mytheme" parent="android:Theme.Holo">
    <item name="android:activatedBackgroundIndicator">@drawable/activated_background</item>
</style>

- The drawable should refer to a file containing a selector like (like you have)

activated_background.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/my_color" android:state_activated="true" />
    <item android:drawable="@android:color/transparent" />
</selector>

colors.xml

<resources>
    <item name="my_color" type="color">#ff0000</item>
</resources>

- Finally, make sure you are applying the theme in your manifest's application tag using

AndroidManifest.xml

android:theme="@style/Theme.mytheme"

Problem

Hi and thanks for reading. I have a problem with my android apps navigation drawer where I cannot change the color from blue - I have went over all the other questions from SO, referred to the android documentation, and have tried everything so far... but still no luck. I really hope someone can help. The code so far: my_background.xml ``` <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Blue still showing up! --> <item android:state_activated="true" android:drawable="@color/lightPink" /> <item android:state_selected="true" android:drawable="@color/lightPink" /> <item android:state_pressed="true" android:drawable="@color/lightPink" /> <item android:state_focused="true" android:drawable="@color/lightPink" /> <item android:drawable="@color/lightPink" /> </selector> ``` styles.xml ``` <item name="android:activatedBackgroundIndicator">@drawable/my_background</item> ``` fragment_navigation_drawer.xml ``` <ListView 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" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" android:background="?android:attr/activatedBackgroundIndicator" android:listSelector="@drawable/my_background" tools:context="com.randompractice.app.NavigationDrawerFragment" /> ``` I have been stuck on this for 24 hours now and it is driving me crazy. For such a silly little change that my curiosity told me to implement, has turned into a research project. Can anybody see what I am doing wrong?

Original source