佈局使用selector不變色問題

在工做的時候想給LinearLayout添加一種變色效果,結果按照最初的思路設置沒有任何效果    經過查找各類資料發現了問題所在,當給LinearLayout,RelativeLayout等設置selector時,須要給他們設置android:clickable="ture"屬性java

android:background="@drawable/selector_hot_dest"
android:clickable="true"
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/item_pop_hot_destination_bg"
android:state_pressed="false"/>
<item android:drawable="@drawable/item_pop_hot_destination_bg_press"
android:state_selected="true"/>
<item android:drawable="@drawable/item_pop_hot_destination_bg_press"
android:state_pressed="true"/>
</selector>
相關文章
相關標籤/搜索