A 15 year old girl saves 40 elementary school kids and that's why she is my hero!

Android: Can’t Set Styles via a Selector

29. March 2011 17:10 by Scott in   //  Tags:   //   Comments (0)

Something incredibly disappointing that I found out today.  When you create a selector in Android, there is currently no way to set styles via a selector.

What do I mean?  Well look below:

<?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:state_pressed="true"
           style="@style/CategoryButtonPressedStyle" /> <!-- pressed -->
     <item android:state_focused="true"
           style="@style/CategoryButtonFocusedStyle" /> <!-- focused -->
     <item style="@style/CategoryButtonStyle" /> <!-- default -->
 </selector>

I currently have the styles set in a selector for a button.  From what I found out you can only set drawables attributes to selectors instead.  What if I don’t want a graphic overlaying my button.  I want to do it programmatically instead.  This is incredibly disappointing because well CSS can do this. 

Looks like they don’t have plans for this either.

Just a rant.

Scott