我有一個XML文件,它定義了列表中一行的佈局。佈局在最外層是LinearLayout。在內部,還有另一個LinearLayout,它佔據了該行右側30個下傾角。當我不想要它時查看複製的父狀態
我有一個可繪製的集作爲外部LinearLayout的背景資源。這用作該行的選擇器。該行通常是白色的。當你點擊它時,它是綠色的。
我也有一個可繪製的設置作爲內部LinearLayout的背景資源,它佔用了該行的右傾30次。這可繪製如下所示:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:state_pressed="false"
android:drawable="@color/light_blue_pressed" />
<item android:state_selected="true"
android:state_pressed="true"
android:drawable="@color/light_blue_pressed" />
<item android:state_selected="false"
android:state_pressed="false"
android:drawable="@color/light_blue" />
<item android:state_selected="false"
android:state_pressed="true"
android:drawable="@color/light_blue_pressed" />
</selector>
我增加了一個OnClickListener到這種內在的LinearLayout所以,當你點擊它,從light_blue的變化的LinearLayout的顏色light_blue_pressed。
但是,單擊行的任何其他位置(讀取:外部LinearLayout)不應該更改內部LinearLayout的顏色,並且它會。
我已將android:duplicateParentState
選項添加到我的內部LinearLayout中,其值爲false
並且問題仍在發生。
<LinearLayout
android:id="@+id/item_warning_level"
android:layout_width="30dip"
android:layout_height="match_parent"
android:background="@drawable/selector_light_blue"
android:duplicateParentState="false" />
任何想法?
但我想在我的ListView上有一個選擇器。我有另一個選擇器用於整行(構成大部分行的空白區域)。 30dip藍色空間本質上是一個按鈕。點擊該按鈕會帶你到某個地方。點擊該行的其他地方即可選擇該行。 – Andrew