Thanks.  ColorStateList did the trick!

>
>
>
>
>
> > I would like to vary the text color of a custom button that I am
> > making depending on which state it is in (enabled, disabled, state
> > pressed).  I know how to use an XML file to describe the different
> > drawables that I need for the different states like so:
>
> > ----
> > In the drawables folder I create this custom_button.xml file
> > ---
> > <?xml version="1.0" encoding="utf-8"?>
> > <selector xmlns:android="http://schemas.android.com/apk/res/android";>
> >         <item
> >                 android:drawable="@drawable/button_enabled"
> >                 android:state_pressed="false" />
> >         <item
> >                 android:drawable="@drawable/button_tap"
> >                 android:state_pressed="true" />
> >         <item
> >                 android:drawable="@drawable/button_inactive"
> >                 android:state_enabled="false" />
> > </selector>
>
> > However, adding android:textColor to each item totally makes the
> > button style invalid.  Even if I create a style in the themes.xml
> > file, I only get a single android:textColor like so:
>
> > -----
> > themes.xml
> > -----
> > <?xml version="1.0" encoding="utf-8"?>
> > <resources>
> >         <style name="CustomButton" parent="@android:style/Widget.Button">
> >         <item name="android:gravity">center_vertical|
> > center_horizontal</item>
> >         <item name="android:textColor">#FF0000ff</item>
> >         <item name="android:textSize">14sp</item>
> >         <item name="android:textStyle">bold</item>
> >         <item name="android:background">@drawable/custom_button</item>
> >         <item name="android:focusable">true</item>
> >         <item name="android:clickable">true</item>
> >     </style>
> > </resources>
>
> > How do I style the textColor when pressed and textColor when disabled
> > states without resorting to a subclass of a Button?
>
> use ColorStateList
>
> pskink

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to