首页 > 其他分享 >android:state_pressed标签失效或android:state_enabled标签失效问题解决

android:state_pressed标签失效或android:state_enabled标签失效问题解决

时间:2023-03-28 17:03:51浏览次数:35  
标签:标签 enabled state pressed 失效 android

问题描述:

android:state_pressed标签失效或android:state_enabled标签失效,点击不会变色,可用/不可用时不会变色。

 

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/purple_200"/>
    <item android:drawable="@color/lawn_green" android:state_enabled="false"/>
    <item android:drawable="@color/dark_gray" android:state_pressed="true"/>
</selector>

 

解决方法:

将三个<item>标签调换顺序,换为:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/dark_gray" android:state_pressed="true"/>
    <item android:drawable="@color/lawn_green" android:state_enabled="false"/>
    <item android:drawable="@color/purple_200"/>
</selector>

问题解决!

 

 

 感想:离谱!太离谱了! TAT

 

标签:标签,enabled,state,pressed,失效,android
From: https://www.cnblogs.com/lysboke/p/17265866.html

相关文章