<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"