# SwitchButton **Repository Path**: bytexiao/SwitchButton ## Basic Information - **Project Name**: SwitchButton - **Description**: About SwitchButton.An beautiful+lightweight+custom-style-easy switch widget for Android,minSdkVersion >= 11 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-27 - **Last Updated**: 2025-11-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SwitchButton SwitchButton.An *beautiful+lightweight+custom-style-easy* switch widget for Android,minSdkVersion >= 14
issues welcome~
![](21879.gif)
Features ------- -depend without third-part library
-without raw files(pictures/drawables etc...), only one java and style.xml file
-drag switch supported
UseAge ------- gradle: ```grovvy repositories { mavenCentral() jcenter() } ... dependencies { implementation 'com.github.zcweng:switch-button:0.0.3@aar' } ``` layout.xml: ```xml ``` Java: ```java SwitchButton switchButton = (com.suke.widget.SwitchButton) findViewById(R.id.switch_button); switchButton.setChecked(true); switchButton.isChecked(); switchButton.toggle(); //switch state switchButton.toggle(false);//switch without animation switchButton.setShadowEffect(true);//disable shadow effect switchButton.setEnabled(false);//disable button switchButton.setEnableEffect(false);//disable the switch animation switchButton.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(SwitchButton view, boolean isChecked) { //TODO do your job } }); ``` Kotlin: ```kotlin val switchButton = findViewById(R.id.switch_button) as SwitchButton switchButton.isChecked = true switchButton.isChecked switchButton.toggle() //switch state switchButton.toggle(false) //switch without animation switchButton.setShadowEffect(true) //disable shadow effect switchButton.isEnabled = false //disable button switchButton.setEnableEffect(false) //disable the switch animation switchButton.setOnCheckedChangeListener(object : SwitchButton.OnCheckedChangeListener { override fun onCheckedChanged(view: SwitchButton?, isChecked: Boolean) { //TODO do your job } }) ``` More Style: ```xml 阴影半径 阴影偏移 阴影颜色 关闭颜色 开启颜色 边框宽度 开启指示器颜色 开启指示器线宽 关闭指示器颜色 关闭指示器线宽 关闭指示器半径 是否选中 是否启用阴影 动画时间,默认300ms 按钮颜色 是否显示指示器,默认true:显示 背景色,默认白色 是否启用特效,默认true ``` ScreenShot ------- Sample Apk:
![](http://qr.api.cli.im/qr?data=https%253A%252F%252Fgithub.com%252Fzcweng%252FSwitchButton%252Fblob%252Fmaster%252Fsample%252Fsample-debug.apk&level=H&transparent=false&bgcolor=%23ffffff&forecolor=%23000000&blockpixel=12&marginblock=1&logourl=&size=280&kid=cliim&key=8144f9f150d38d7d364c923d0b9c87cf)
License ------- MIT, See the [LICENSE] file for details.