ImageButton的选择不工作? [英] ImageButton selector doesn't work?

查看:117
本文介绍了ImageButton的选择不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做的ImageButton为pressed的状态,重点突出,正常的。
我读过引进的ImageButton 这里

I am trying to make ImageButton for state of pressed, focused and normal. I've read introduction of ImageButton here

我在/ RES /绘制/选择保存XML文件。还可以设置的android:SRC =@绘制/ my_selector

I've saved selector XML file in /res/drawable/. Also set the android:src="@drawable/my_selector".

my_selector.xml文件:

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>

我觉得我已经做了正确的ImageButton。但它没有为我工作。

I think I've done correct ImageButton. But it didn't work for me.

什么是错在这里?

请咨询。

推荐答案

标签项目,要责令。
所以pressed第一,突出重点,最后就是默认项目

Item tags should be ordered. So pressed first, focused, and the last is default item

这里

这篇关于ImageButton的选择不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆