【问题标题】:How can add imagebutton click effect?如何添加imagebutton点击效果?
【发布时间】:2014-02-20 05:16:45
【问题描述】:

我正在使用安卓系统。我想在 ImageButton 上添加onClick() 效果,最好是选择后按钮两侧的颜色。我曾尝试使用 alpha 效果。但即使点击后返回,它看起来也很暗。

如何添加ImageButton点击效果?

【问题讨论】:

  • 您能分享您的代码和屏幕截图,说明您已经取得的成就和您想要的吗?

标签: android onclick imagebutton


【解决方案1】:

您可以使用如下选择器 xml:-

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/button_pressed_yellow"
          android:state_pressed="true" />
    <item android:drawable="@drawable/button_focused_orange"
          android:state_focused="true" />
    <item android:drawable="@drawable/button_normal_green" />
</selector>

并将其设置为您的 Button 的 background

【讨论】:

    猜你喜欢
    • 2014-08-21
    • 2013-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多