美文网首页android 技术知识
自定义Shape颜色选择器

自定义Shape颜色选择器

作者: 追梦小乐 | 来源:发表于2017-05-03 11:18 被阅读22次
<item android:state_selected="true">
    <shape android:shape="rectangle">
        <solid android:color="@color/c_white" />
    </shape>
</item>

<item android:state_pressed="true">
    <shape android:shape="rectangle">
        <solid android:color="@color/c_white" />
    </shape>
</item>
<item android:state_focused="true">
    <shape android:shape="rectangle">
        <solid android:color="@color/c_white" />
    </shape>
</item>
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false">
    <shape android:shape="rectangle">
        <solid android:color="@color/c_bg_e5e5e5" />
    </shape>
</item></selector>

假如最外层是一个LinearLayout线性布局,我需要对整个布局起到点击的效果,在UI没有给图的情况下,除了自己定义颜色选择器后,对LinearLayout的根节点下需要加上如下一行代码,否则起不了点击效果:
android:clickable="true"

相关文章

网友评论

    本文标题:自定义Shape颜色选择器

    本文链接:https://www.haomeiwen.com/subject/ckektxtx.html