Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of android:activatedBackgroundIndicator

Tags:

android

colors

Can I change the default color (blue) of the attr android:activatedBackgroundIndicator?

I am developing an application for target 18 and for minimun 11.

Thank you

like image 578
Asaroth_asa Avatar asked Sep 26 '13 20:09

Asaroth_asa


People also ask

How can I change the color of the title bar in Android?

Just go to res/values/styles.edit the xml file to change the color of action bar.

What is attr in Android?

The Attr interface represents an attribute in an Element object. Typically the allowable values for the attribute are defined in a schema associated with the document.


1 Answers

Here is a way to change it on your theme:

Update your theme to apply your custom style on the activatedBackgroundIndicator attribute (here the parent theme is Holo Light but you can of course change it):

<style name="AppTheme" parent="@android:style/Theme.Holo.Light">         <item name="android:activatedBackgroundIndicator">@drawable/list_activated_background</item>     </style> 

In your "drawable" resource folder, create the XML file list_activated_background and define your new background indicator, for example:

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">      <item android:state_activated="true" android:drawable="@color/OrangeLight" />    <item android:state_checked="true" android:drawable="@color/OrangeDark" />    <item android:state_pressed="true" android:drawable="@color/OrangeDark" />    <item android:drawable="@android:color/transparent" />   </selector> 

Then just be sure you are calling your custom theme in the manifest file with android:theme="@style/AppTheme" in this case for example.

like image 62
Yoann Hercouet Avatar answered Sep 24 '22 07:09

Yoann Hercouet