小编Dou*_*erg的帖子

Android ImageButton 状态没有改变

我的 ImageButton 不改变状态有问题。当我单击或触摸按钮时,它保持相同的图像。这是我用作选择器的 XML。

<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
 android:state_focused="true"
 android:state_pressed="false"
 android:drawable="@drawable/pushed" />
<item
 android:state_focused="true"
 android:state_pressed="true"
 android:drawable="@drawable/pushed" />
<item
 android:state_focused="false"
 android:state_pressed="true"
 android:drawable="@drawable/pushed" />
<item  
 android:drawable="@drawable/default" />
</selector>
Run Code Online (Sandbox Code Playgroud)

我从我的 main.xml 中调用这个选择器作为

android:background="@drawable/imagechoice"
Run Code Online (Sandbox Code Playgroud)

imagechoice.xml 是带有选择器的文件

我不明白为什么这不起作用,除非我必须有一些 Java 代码,但我所看到的一切都表明这应该有效。

android state selector imagebutton

5
推荐指数
1
解决办法
4316
查看次数

标签 统计

android ×1

imagebutton ×1

selector ×1

state ×1