in your res/drawable folder, put an xml that contains (sample.xml): <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/focused" /> <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/focusedpressed" /> <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/pressed" /> <item android:drawable="@drawable/defaultbutton" /> </selector>
then on your button, use this xml as your background. (background="@drawable/sample") check out this tutorial from anddev.org about selectors http://www.anddev.org/tinytutcustom_button_backgrounds-better_imagebutton-t4298.html -Marc On Sun, Aug 23, 2009 at 3:13 PM, sdphil <phil.pellouch...@gmail.com> wrote: > > how do I specify different images for an ImageButton when the state > changes (i.e. pressed). > > <ImageButton android:id="@+id/Btn1" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:src="@drawable/btn1" > android:background="@color/transparent"/> > > In a standard button the color changes to orange when pressed, I'd > like to change a custom image button with a different image. > > tia. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---