android android:state_focused 无效

背景:不生效xml如下所示,state_focused="true" 样式永远不会生效

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:drawable="@drawable/focus_background_new"/>
    <item android:state_pressed="true">
        <shape>
            <corners android:topLeftRadius="@dimen/card_high_expand_radius_left_top"/>
            <solid android:color="@color/button_notice_press"/>
        </shape>
    </item>
</selector>

原因如下图所示: 

 解决办法:在selector中都使用shape样式,而不是混合drawable和shape的样式

猜你喜欢

转载自blog.csdn.net/chengzhenjia/article/details/131557390