Skip to content

Instantly share code, notes, and snippets.

@jayde-bog
Created February 4, 2020 01:40
Show Gist options
  • Save jayde-bog/ce9ccd1cb251a60b28a9d0e6b277963e to your computer and use it in GitHub Desktop.
Save jayde-bog/ce9ccd1cb251a60b28a9d0e6b277963e to your computer and use it in GitHub Desktop.
Android SwitchCompat custom style
<androidx.appcompat.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:thumb="@drawable/more_switch_thumb"
app:track="@drawable/more_switch_track" />
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp">
<shape
android:shape="oval">
<size android:width="22dp" android:height="22dp" />
<solid android:color="#FFFFFF" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<shape>
<solid android:color="#FF5A00" />
<corners android:radius="13dp" />
<size android:height="26dp" />
</shape>
</item>
<item >
<shape>
<solid android:color="#C6C6C6" />
<corners android:radius="13dp" />
<size android:height="26dp" />
</shape>
</item>
</selector>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment