I am trying to change the styling of Switch, When i add Thumb
and Track
properties to the layout, it hides the Switch
from the layout. If i remove Thumb
and Track
from the layout, it displays custom Switch. Kindly guide me how to change Switch
styling.
<Switch
android:layout_width="200dp"
android:layout_height="200dp"
android:id="@+id/switchNotifications"
android:layout_centerHorizontal="true"
android:paddingTop="150dp"
android:text="@string/notification_settings"
android:textColor="@color/white"
android:checked="true"
android:track="@drawable/track"
android:thumb="@drawable/thumb"
/>
Thumb.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/gray_track" />
<item android:state_pressed="true" android:drawable="@drawable/color_thumb" />
<item android:state_checked="true" android:drawable="@drawable/color_thumb" />
<item android:drawable="@drawable/gray_track" />
</selector>
Track.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="false" android:drawable="@drawable/color_thumb" />
<item android:drawable="@drawable/gray_track" />
</selector>
ColorThumb
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<size android:height="40dp" />
<gradient android:height="40dp" android:startColor="@color/tabAccessoryButtonSelected" android:endColor="@color/tabAccessoryButtonSelected"/>
</shape>
GrayTrack
<size android:height="40dp" />
<gradient android:height="40dp" android:startColor="@color/tabAccessoryButtonSelected" android:endColor="@color/tabAccessoryButtonSelected"/>