Hi I wanna have a button that changes the image (drawableTop) on focus. I tried almost everything but I cannot get it working. I'm using Android 2.0 SDK
In res/drawable I have my two images. One for button's normal state, and another for focused/pressed state. On that folder I also have this xml file: btn_home.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/ic_home" /> <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/ic_home" /> <item android:state_enabled="true" android:drawable="@drawable/ic_home_off" /> </selector> Then, I create this xml on /res/values: styles.xml <?xml version="1.0" encoding="utf-8"?> <resources> <style name="ButtonHome" parent="@android:style/Widget.Button"> <item name="android:gravity">center_vertical| center_horizontal</item> <item name="android:padding">5dip</item> <item name="android:textSize">13sp</item> <item name="android:textColor">#FFFFFFFF</item> <item name="android:shadowColor">#FF000000</item> <item name="android:shadowDx">0</item> <item name="android:shadowDy">-1</item> <item name="android:shadowRadius">0.2</item> <item name="android:drawableTop">@drawable/btn_home</item> <item name="android:focusable">true</item> <item name="android:clickable">true</item> </style> </resources> Then, on my Layout I put a button that references to the created style: <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/btnHome" android:text="Home" android:layout_weight="1" style="@style/ ButtonHome"/> I tested it on the emulator, and it don't shows me applied styles. I cannot see any changes on any state of the button (normal, focused or pressed). But when I use the same approach to apply an style to the button background, it works perfectly :( Please help me TIA -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

