我有一个switch ,当它打开时,我希望轨迹 colored颜色 是橙色,如果它被关闭,我希望它是灰色的.但是,我不想搞乱现有thhum.xml和track.xml文件的大小.
CUSTOM_Thumb.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size
android:width="30dp"
android:height="30dp" />
<corners android:radius="15dp" />
<solid android:color="@color/white" />
</shape>
Custom_track.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size
android:width="60dp"
android:height="30dp" />
<corners android:radius="15dp" />
<solid android:color="@color/cold_grey06" />
</shape>
切换交换机到交换机
<Switch
android:id="@+id/rememberSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:thumb="@drawable/custom_thumb"
android:track="@drawable/custom_track" />