【发布时间】:2014-11-05 16:35:12
【问题描述】:
我正在尝试创建一个 ImageButton 来根据它是否启用来更改它的图标。我创建了以下文件:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/icn_increase_inactive" />
<item android:state_enabled="true" android:drawable="@drawable/icn_increase_active" />
</selector>
在启用和禁用之间切换状态时,没有任何变化。我还尝试创建自己的 ImageButton 来扩展 ImageButton 并尝试手动切换状态,但在 ImageButton 中,它将可绘制对象加载为 BitmapDrawable 而不是 StateListDrawable。在图像按钮之外加载时,它可以作为 StateListDrawable 工作。有什么想法吗?
【问题讨论】:
-
你试过
<item android:state_enabled="false" android:drawable="@drawable/icn_increase_inactive" />
标签: android android-imagebutton