Android highlight ImageButton onclick
Is there a way to highlig开发者_运维百科ht an ImageButton
when it's pressed?
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.
精彩评论