Seems like selector file for track
attribute is not working properly for RTL.
LTR track
and thumb
.
RTL track
and thumb
. Here thumb
is changed properly, but track
images are still unchanged as it should display map icon on the right.
<androidx.appcompat.widget.SwitchCompat
android:background="@drawable/selector_switch_track"
android:elevation="6dp"
android:outlineProvider="background"
android:thumb="@drawable/selector_switch_thumb"
app:track="@drawable/selector_switch_track" />
selector_switch_track.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true">
<item android:state_checked="true">
<layer-list>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/global_white" />
<corners android:radius="@dimen/margin_100dp" />
</shape>
</item>
<item android:drawable="@drawable/layer_switch_thumb_map_off" android:gravity="start" android:right="@dimen/margin_56dp" />
<item android:drawable="@drawable/layer_switch_thumb_list_off" android:gravity="end" android:left="@dimen/margin_56dp" />
</layer-list>
</item>
<item android:state_checked="false">
<layer-list>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/global_white" />
<corners android:radius="@dimen/margin_100dp" />
</shape>
</item>
<item android:drawable="@drawable/layer_switch_thumb_map_off" android:gravity="start" android:right="@dimen/margin_56dp" />
<item android:drawable="@drawable/layer_switch_thumb_list_off" android:gravity="end" android:left="@dimen/margin_56dp" />
</layer-list>
</item>
</selector>