I have not found an exact solution to this problem, but you can separate TextView and Swich as follows:
<RelativeLayout android:layout_width="wrap_content" android:layout_height="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="YOUR SWITCH TEXT HERE"/> <Switch android:id="@+id/switch" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" /> </RelativeLayout>
And use the setOnCheckedChangeListener switch in your code.
source share