You can create a selector xml file and place resource references for all the different states within it, then use the selector.xml file as your button background. Here is a push-button example
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="false" android:drawable="@drawable/ global_btn_off" /> <item android:state_pressed="true" android:drawable="@drawable/ global_btn_on" /> </selector> There are many more button states available, look it up in the docs. On Aug 22, 6:58 am, Ash <anan...@gmail.com> wrote: > Hi All, > > Wondering if anyone can advice me on the following. I wish to create a > button which will allow me to have: > 1. a color when the button is disabled > 2. a color when the button is enabled but idle > 3. a color when the button is enabled and pressed > 4. a border which will change color upon some external activity. > > After reading this tutorial > (http://blog.androgames.net/40/custom-button-style-and-theme/) I have to able > to achieve steps 1-3. However, I am struggling to achieve step 4. Also note > that step 4 will need to happen programmatically as my application > implements a 3rd party observer which notifies me when a task is active. > > Can someone please guide me on how to achieve step 4. Ideally I would like > to use the shape that is described in the above link with a border which I > can control via my code? Please advice. > > Thanks. -- 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