I've got a custom LinearLayout with a widget Switch
and TextView
child. I'd like to be able to click the area covered by the LinearLayout
, so I set clickable=true
to the LinearLayout
, but Switch
is not triggered.
I wanted to trigger on Switch
when I click on the LinearLayout
.
I also tried with android:duplicateParentState="true"
in Switch
but did't worked.
Can I achieve this from XML
?
<LinearLayout
android:background="@drawable/ripple"
android:clickable="true"
android:focusable="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Switch
android:clickable="false"
android:paddingTop="8dp"
android:text="Visibility"
android:textSize="16sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:clickable="false"
android:layout_marginRight="58dp"
android:maxLines="3"
android:text="@string/visibility_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="58dp" />
</LinearLayout>