开发者

Android highlight ImageButton onclick

开发者 https://www.devze.com 2023-01-04 15:58 出处:网络
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 differen

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消