I want to create a switch which looks like this
i have done that in this way
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Available"
android:textColor="#82BCB4"
android:textSize="20sp"
/>
<Switch
android:id="@+id/theSwitchId"
android:textOn=""
android:textOff=""
android:layout_width="wrap_content"
android:layout_height="20dp"
android:thumbTextPadding="5dp"
android:switchMinWidth="90dp"
android:layout_marginStart="40dp"
android:minHeight="60dp"
android:layout_gravity="center|center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UnAvailable"
android:layout_marginStart="40dp"
android:textColor="#224e6d"
android:textSize="20sp"
/>
</LinearLayout>
i am not able to change the height of the switch and it doesnt look how its in this image. Please help me with this
all you need to do is just use a custom drawable as track of switch
this is the code for custom drawable:
Further make these modification to your existing layout add android:thumbTint="@android:color/holo_blue_dark" or any color that meets your requirement
hope this helps
click here to view the resulting screenshot
screenshot