Android RelativeLayout上的选择器不工作
我知道有很多关于这方面的话题,我都读了。但我仍然无法让选择器在RelativeLayout上工作 所以我需要你的帮助。这是我的密码 选择器:Android RelativeLayout上的选择器不工作,android,android-layout,view,android-relativelayout,Android,Android Layout,View,Android Relativelayout,我知道有很多关于这方面的话题,我都读了。但我仍然无法让选择器在RelativeLayout上工作 所以我需要你的帮助。这是我的密码 选择器: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:drawable="@d
<?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/selected_background"/>
<item android:state_pressed="true" android:drawable="@drawable/selected_background" />
<item android:state_selected="true" android:drawable="@drawable/selected_background" />
<item android:drawable="@drawable/unselected_background" />
布局:
<LinearLayout
android:id="@+id/calendarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="afterDescendants"
android:clickable="false"
android:focusable="false"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:clickable="false"
android:descendantFocusability="afterDescendants"
android:weightSum="3">
<RelativeLayout
android:id="@+id/calendarItem1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector_dashboard_calendar_icon"
android:clickable="true"
android:focusable="true"
android:padding="3dp">
<TextView
android:id="@+id/dateTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:clickable="false"
android:lines="2"
android:padding="3dp"
android:textColor="@color/white"
android:textSize="12dp" />
</RelativeLayout>
</LinearLayout>
...
</LinearLayout>
...
正如您所看到的,我使子视图不可单击且不可聚焦,所有父布局(我放置选择器的布局除外)都位于子视图的可聚焦性之后。发生的情况是,只有在单击布局时背景才会更改,但我希望在选定状态下更改它