Is there a way to highlight an ImageButton
when it's pressed?
views:
423answers:
1
+3
A:
You can define a drawable via XML and use the selector, like below, to use different (i.e. highlighted) images for different button states:
i.e. res/drawable/button.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bg_catlocfilter" android:state_pressed="false" />
<item android:drawable="@drawable/bg_catlocfilter_dark" android:state_pressed="true" />
<item android:drawable="@drawable/bg_catlocfilter" android:state_focused="false" />
<item android:drawable="@drawable/bg_catlocfilter_dark" android:state_focused="true" />
</selector>
Use this resource then for the ImageButton view.
Mathias Lin
2010-06-26 06:50:43
I was typing the same answer but you got there first..
primalpop
2010-06-26 07:01:37