Hello,

I am facing the following problem. I have a column of ImageButtons.
When the button changes state because the user presses the button
I need the both the button image and the button background to change.
However at the following site I don't see how to change the background
of the ImageButton when the user presses it.

http://developer.android.com/reference/android/widget/ImageButton.html

Changing the background is important because I need the image to fade
into the background, and since different phones have different screen
heights,
I cannot make the image the same size as the button, I need the button to
change size and leave the image size fixed.

The ImageButton background must match the image background, but I don't
see how to do this in the XML.

Instead of just:

 <?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android";>
     <item android:state_pressed="true"
           android:drawable="@drawable/button_pressed" /> <!-- pressed -->
     <item android:state_focused="true"
           android:drawable="@drawable/button_focused" /> <!-- focused -->
     <item android:drawable="@drawable/button_normal" /> <!-- default -->
 </selector>


I would like to specify the background property as well such as:

 <?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android";>
     <item android:state_pressed="true"
           android:drawable="@drawable/button_pressed"
           android:background="#FF0000" /> <!-- pressed -->
     <item android:state_focused="true"
           android:drawable="@drawable/button_focused"
           android:background="#00FF00" /> <!-- focused -->
     <item android:drawable="@drawable/button_normal"
           android:background="#0000FF" /> <!-- default -->
 </selector>


I was wondering whether it is legal to specify any property pertaining
to the ImageButton in its selector (such as the button's background
color rather than just the image). Any ideas on how to elegantly solve
the problem of having an ImageButton's background and image
change simultaneously when unpressed/pressed/selected?

Thanks,

John Goche

-- 
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

Reply via email to