An iOS-style switch control for android.
dependencies {
implementation 'io.github.vejei.cupertinoswitch:cupertinoswitch:x.y.z'
}
<io.github.vejei.cupertinoswitch.CupertinoSwitch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:trackOffColor="#dddddd"
app:trackOnColor="@color/purple_500"/>
For more samples, check the sample app.
Attribute | Description | Type | Sample Value |
---|---|---|---|
switchWidth |
The width of whole switch. | dimension |
100dp |
switchHeight |
The height of whole switch. | dimension |
20dp |
switchDuration |
The duration of the switch slider animation, in milliseconds. | integer |
1000 |
trackOnColor |
The color of the switch track in the on state. | color |
#fa0000 |
trackOffColor |
The color of the switch track in the off state. | color |
#dddddd |
sliderColor |
The slider's color | color |
#000000 |
sliderRadius |
The slider's radius | dimension |
20dp |
sliderShadowEnabled |
Whether the slider turns on the shadow. | boolean |
true |
sliderShadowColor |
The color of the slider shadow | color |
#eeeeee |
sliderShadowRadius |
The radius of the slider shadow | dimension |
10dp |