In a layout
I use a button
which I set its textColor
to a drawable as follows :
@drawble/text_color_drawable :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- disabled state -->
<item android:state_enabled="false" android:color="@color/disabled_text_color" />
<item android:color="@color/main_text_color"/>
</selector>
@color/main_text_color :
<color name="main_text_color">#9797A3</color>
But when I use this drawable
called text_color_drawable
as textColor
:
android:textColor="@drawable/text_color_drawable"
I get an exception : Exception raised during rendering: Color value text_color_drawable must start with #
Am I doing something wrong ?
Thank you
The problem may be@drawble/text_color_drawable
: it shouldn't be a 'drawable', but rather a
'color'. Basically what you currently have is a StateListDrawable
, but what you really want is a ColorStateList
. Both are quite similar, but live in different places in the resources.
That being said, try moving the file from res/drawable
to res/color
. When you then assign the resource as text color, it should say: android:textColor="@color/text_color_drawable"