Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
2.1 kB
4
Indexable
Never
custom_track - >

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="false">
        <shape android:shape="rectangle">
            <corners android:radius="15dp" />
            <solid android:color="#29787880" />
            <size android:height="30dp" />
            <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
        </shape>
    </item>
    <item android:state_checked="true">
        <shape android:shape="rectangle">
            <corners android:radius="15dp" />
            <solid android:color="@color/pinkish_orange" />
            <size android:height="30dp" />
            <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
        </shape>
    </item>
</selector>
4:53
custom_thumb - > 

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <solid android:color="#ffffff" />

    <size
        android:width="30dp"
        android:height="30dp" />
    <corners android:radius="15dp" />
</shape>
4:54
SCBSwitch


<style name="SCBSwitch" parent="Theme.AppCompat.Light">
    <!-- active thumb & track color (30% transparency) -->
    <item name="colorControlActivated">@color/colorPrimary</item>

    <!-- inactive thumb color -->
    <item name="colorSwitchThumbNormal">@color/white</item>

    <!-- inactive track color (30% transparency) -->
    <item name="android:colorForeground">#42221f1f</item>


</style>




<androidx.appcompat.widget.SwitchCompat
    android:id="@+id/switch_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:rotation="180"
    android:theme="@style/SCBSwitch"
    android:thumb="@drawable/custom_thumb"
    app:layout_constraintBottom_toBottomOf="@+id/delivery_textview"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="@+id/delivery_textview"
    app:track="@drawable/custom_track" />