我想在switchcompat的拇指上添加一个颜色渐变。
<androidx.appcompat.widget.SwitchCompat
android:layout_width="50dp"
android:checked="true"
android:layout_height="50dp"
android:thumb="@drawable/switch_thumb"
/>
drawable switch_thumb.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<gradient
android:startColor="@color/thumb_start_gradient"
android:endColor="@color/thumb_end_gradient"/>
</shape>
</item>
<item
android:bottom="2dp"
android:left="1dp"
android:right="1dp"
android:top="1dp">
<shape android:shape="oval">
<gradient
android:startColor="@color/thumb_start_gradient"
android:endColor="@color/thumb_end_gradient"/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#0f0"/>
</shape>
</item>
</layer-list>
但是它甚至没有画出开关。