• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps change-text-color-based-on-theme-in-a-selector-with-different-states

Hi guys,

I have an issue with my app:

I try to change the color based on my theme. My TextView is using color-selector with different states for enabled and disabled and I want to use my theme based color in this selector.

I have followed this solution: http://stackoverflow.com/questions/12703757/android-themes-defining-colours-in-custom-themes

My selector used as android:textColor in my view looks like this:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:color="#ffffff" />
<item android:state_enabled="false" android:color="?attr/ThemeTest"/>
</selector>

with ThemeTest being my custom attribut which has a color assigned in my themes. If I use this selector as my textColor, the color is actually not what I picked but just a simple plain RED! HOWEVER if I use the custom attribut directly in my view

android:textColor="?ThemeTest"

then it works but I obviously want to do this based on the change of state of my view...

Does anybody understand this behaviour and know how to fix it? Thanks in advance!


btw: I have posted that question on stackoverflow as well but it didnt get any attention so far thats why I repost it here in hope someone is able to help me out :)

thanks a lot,
ftb
 
Back
Top Bottom