image.png
布局
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:thumb="@drawable/switch_setting_white_circle_selector"
android:track="@drawable/switch_selector_setting" />
switch_setting_white_circle_selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/switch_setting_circle_selected" android:state_checked="true"/>
<item android:drawable="@drawable/switch_setting_circle_normal" android:state_checked="false"/>
</selector>
switch_setting_circle_selected
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke android:color="@color/blue_00" android:width="1dp"/>
<solid android:color="@color/white" />
<size
android:width="20dp"
android:height="20dp" />
</shape>
switch_setting_circle_normal
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke android:color="@color/hui_d8" android:width="1dp"/>
<solid android:color="@color/white" />
<size
android:width="20dp"
android:height="20dp" />
</shape>
switch_selector_setting
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/switch_setting_bg_selected" android:state_checked="true"/>
<item android:drawable="@drawable/switch_setting_bg_normal" android:state_checked="false"/>
</selector>
switch_setting_bg_selected
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/blue_00"/>
<size android:width="40dp"
android:height="21dp"/>
<corners android:radius="21dp"/>
</shape>
switch_setting_bg_normal
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/hui_d8"/>
<size android:width="40dp"
android:height="21dp"/>
<corners android:radius="21dp"/>
</shape>
网友评论