SwitchView is beautiful switch widget for Android
- Without third-part library
- Without raw files(pictures/drawables etc...), only one Kotlin file
- Android Sdk 14+
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation 'com.github.BasetEsmaeili:SwitchView:1.0'
}
<com.baset.switchview.SwitchView
android:id="@+id/switch_preference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:switch_elevation="8dp" />
Name | Type |
---|---|
animationDuration | integer |
switch_on_color | color |
switch_off_color | color |
switch_toggle_color | color |
switch_elevation | dimension |
checked | boolean |
switch_preference.setOnCheckedChangeListener(object : OnCheckedChangeListener {
override fun onCheckedChanged(view: SwitchView, isChecked: Boolean) {
// DO SOME THING
}
})
switch_preference.setChecked(true)
switch_preference.isChecked()
switch_preference.setAnimationDuration(500)
switch_preference.setBackgroundColor(checkedColor,uncheckedColor)
switch_preference.setSwitchToggleColor(color)
switch_preference.setSwitchElevation(8f)
Copyright [2020] [Baset Esmaeili]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Baset Esmaeili
Email: baset.esmaili0@gmail.com