- <LinearLayout
- android:clickable="true"
- android:focusable="true">
- <TextView
- android:duplicateParentState="true"/>
- android:textColor="@drawable/selector_setting_txt"
- </LinearLayout>
- <?xml version="1.0" encoding="utf-8"?>
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="true" android:color="@color/white"></item>
- <item android:color="@color/txt_title"></item>
- </selector>
在父控件中添加android:clickable=“true” android:focusable=“true”,而在子控件中添加android:duplicateParentState=“true”子控件就能获得父控件的点击事件