ImageButton 选择器不起作用?
我正在尝试使 ImageButton 处于按下、聚焦和正常状态。 我已经阅读了 ImageButton 的介绍 这里
我保存了选择器 XML文件位于 /res/drawable/ 中。还要设置 android:src="@drawable/my_selector"
。
my_selector.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn_unfocus" /> <!-- default -->
<item android:state_pressed="true"
android:drawable="@drawable/btn_onpress" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/btn_onfocus" /> <!-- focused -->
</selector>
我认为我已经完成了正确的 ImageButton。但这对我不起作用。
这里出了什么问题?
请指教。
I am trying to make ImageButton for state of pressed, focused and normal.
I've read introduction of ImageButton here
I've saved selector XML file in /res/drawable/. Also set the android:src="@drawable/my_selector"
.
my_selector.xml file :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn_unfocus" /> <!-- default -->
<item android:state_pressed="true"
android:drawable="@drawable/btn_onpress" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/btn_onfocus" /> <!-- focused -->
</selector>
I think I've done correct ImageButton. But it didn't work for me.
What is wrong here ?
Please advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
应订购物品标签。
所以先按下,聚焦,最后一个是默认项目
请参阅这里
Item tags should be ordered.
So pressed first, focused, and the last is default item
Refer Here
你理解错了。
试试这个。
You're getting it wrong.
Try this.