I am using Navigation drawer using this example. I want just change blue color to orange color how could I do this? I mean change listview selector color, actionbar selctor color everything.
6 Answers
You can use a selector
in drawable folder have selector.xml as below
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/press" />
<item android:state_focused="false"
android:drawable="@drawable/normal" />
</selector>
In drawable folder press.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FF9D21"/>
</shape>
In drawable foldernormal.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#8BC7EB"/>
</shape>
In the drawer_list_item.xml
android:background="@drawable/selector"
For styling the bar
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<item name="android:background">@style/MyActionBar</item>
<!-- API 11 theme customizations can go here. -->
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@drawable/press</item>
</style>
</resources>
In your manifest
<activity
android:name=".MainActivity"
android:theme="@style/MyActionBar"
android:label="@string/app_name">
You can specify the theme for a particular activity instead of entire application.
More information
http://android-developers.blogspot.in/2011/04/customizing-action-bar.html
https://developer.android.com/training/basics/actionbar/styling.html
Snap shot

- 132,755
- 26
- 225
- 256
-
it's about only customize listView or actionbar too? – bauer9664 Sep 12 '13 at 09:25
-
@bauer9664 its only for the drawer list items. – Raghunandan Sep 12 '13 at 09:26
-
@bauer9664 use styles to change the bar color https://developer.android.com/training/basics/actionbar/styling.html – Raghunandan Sep 12 '13 at 09:32
-
@bauer9664 check the snap shot. the bar color is changed to orange. The snap does not look good taken from emulator – Raghunandan Sep 12 '13 at 09:51
-
You should also include `android:layout_height=""` and `android:layout_width=""` attributes to selector or Android Studio/Gradle won't compile your app – Kurt Wagner Sep 02 '14 at 21:33
You need to use selectors.
Check this tutorial for more. customizing listviews

- 2,076
- 2
- 15
- 17
For ActionBar backgroownd:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarItemBackground">@drawable/bg_actionbar</item>
</style>
</resources>

- 737
- 7
- 6
I would like to contribute to the answer given by @Raghunandan. In the list you can distinguish between items clicked (android:state_pressed) from items activated (android:state_activated), so if you click on the item in the list that is activated, the click is visualized.
Create an activated.xml under the drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#6A6A6A"/>
</shape>
And modify the selector.xml adding the state_activated modifier:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/press" />
<item android:state_activated="true"
android:drawable="@drawable/activated" />
<item android:state_focused="false"
android:drawable="@drawable/normal" />
</selector>

- 1,956
- 2
- 28
- 35
Use Selector to achieve this. You can use either @drawable
or @color
.
item android:drawable="@drawable/list_item_bg_pressed" android:state_pressed="true"/>
item android:drawable="@drawable/list_item_bg_normal" android:state_activated="false"/>
item android:drawable="@drawable/list_item_bg_selected" android:state_activated="true"/

- 2,826
- 5
- 27
- 38

- 11
- 3