1、pressed、selected、default 的顺序不对引起的问题。
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:Android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/login_press" android:state_focused="true"/>
<item android:drawable="@drawable/login_press" android:state_selected="true"/>
<item android:drawable="@drawable/login_press" android:state_pressed="true"/>
<item android:drawable="@drawable/login_press" android:state_enabled="false"/>
<item android:drawable="@drawable/login_normal"/> <!-- 这行,放在最后面就成功了>
</selector>
2、要对View.OnClickListener进行监听,不要使用OnTouchListener。
3、不能使用重复名字的文件,
注意 selector的文件名名称不能和drawable、mipmap系列文件夹下的文件名称一致。
4、最好参照google的官方example的例子来做。
https://developer.android.com/guide/topics/resources/drawable-resource.html
文章评论
comentou em 18 de agosto de 2011 às 01:51. Caraca!!! Então tá explicado… eu achando q Kristen tinha melhorado, é tudo culpa da make escândalo!!! Julia, que inÃerÂvcl… ficou perfeito!
Articles like these put the consumer in the driver seat-very imatotpnr.