{"id":13639358,"url":"https://github.com/zcweng/SwitchButton","last_synced_at":"2025-04-19T22:32:16.056Z","repository":{"id":41297297,"uuid":"77226212","full_name":"zcweng/SwitchButton","owner":"zcweng","description":"SwitchButton.An beautiful+lightweight+custom-style-easy switch widget for Android,minSdkVersion \u003e= 11","archived":false,"fork":false,"pushed_at":"2024-01-12T02:57:56.000Z","size":1853,"stargazers_count":2675,"open_issues_count":39,"forks_count":415,"subscribers_count":43,"default_branch":"master","last_synced_at":"2024-10-29T17:41:29.599Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/zcweng/SwitchButton","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zcweng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-12-23T13:09:26.000Z","updated_at":"2024-10-26T12:03:20.000Z","dependencies_parsed_at":"2024-01-14T11:05:27.491Z","dependency_job_id":null,"html_url":"https://github.com/zcweng/SwitchButton","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcweng%2FSwitchButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcweng%2FSwitchButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcweng%2FSwitchButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcweng%2FSwitchButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zcweng","download_url":"https://codeload.github.com/zcweng/SwitchButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223100261,"owners_count":17087388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:00:59.848Z","updated_at":"2024-11-09T09:30:51.679Z","avatar_url":"https://github.com/zcweng.png","language":"Kotlin","readme":"# SwitchButton\nSwitchButton.An *beautiful+lightweight+custom-style-easy* switch widget for Android,minSdkVersion \u003e= 14\u003cbr\u003e\nissues welcome~\u003cbr\u003e\n![](21879.gif)\u003cbr\u003e\n\nFeatures\n-------\n-depend without third-part library\u003cbr\u003e\n-without raw files(pictures/drawables etc...), only one java and style.xml file\u003cbr\u003e\n-drag switch supported\u003cbr\u003e\n\n\nUseAge\n-------\ngradle:\n```grovvy\nrepositories {\n    mavenCentral()\n    jcenter()\n}\n\n...\n\ndependencies {\n    implementation 'com.github.zcweng:switch-button:0.0.3@aar'\n}\n```\n\nlayout.xml:\n```xml\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              android:layout_width=\"match_parent\"\n              android:layout_height=\"match_parent\"\n              xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n              android:orientation=\"vertical\"\u003e\n\n    \u003ccom.suke.widget.SwitchButton\n        android:id=\"@+id/switch_button\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"/\u003e\n\n\u003c/LinearLayout\u003e\n```\n\nJava:\n```java\nSwitchButton switchButton = (com.suke.widget.SwitchButton)\n    findViewById(R.id.switch_button);\n\nswitchButton.setChecked(true);\nswitchButton.isChecked();\nswitchButton.toggle();     //switch state\nswitchButton.toggle(false);//switch without animation\nswitchButton.setShadowEffect(true);//disable shadow effect\nswitchButton.setEnabled(false);//disable button\nswitchButton.setEnableEffect(false);//disable the switch animation\nswitchButton.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {\n    @Override\n    public void onCheckedChanged(SwitchButton view, boolean isChecked) {\n        //TODO do your job\n    }\n});\n\n\n```\n\nKotlin:\n```kotlin\nval switchButton = findViewById\u003cView\u003e(R.id.switch_button) as SwitchButton\n\nswitchButton.isChecked = true\nswitchButton.isChecked\nswitchButton.toggle() //switch state\nswitchButton.toggle(false) //switch without animation\nswitchButton.setShadowEffect(true) //disable shadow effect\nswitchButton.isEnabled = false //disable button\nswitchButton.setEnableEffect(false) //disable the switch animation\nswitchButton.setOnCheckedChangeListener(object : SwitchButton.OnCheckedChangeListener {\n    override fun onCheckedChanged(view: SwitchButton?, isChecked: Boolean) {\n        //TODO do your job\n    }\n})\n\n\n```\n\nMore Style:\n```xml\n\u003cattr name=\"sb_shadow_radius\" format=\"reference|dimension\"/\u003e       阴影半径\n\u003cattr name=\"sb_shadow_offset\" format=\"reference|dimension\"/\u003e       阴影偏移\n\u003cattr name=\"sb_shadow_color\" format=\"reference|color\"/\u003e            阴影颜色\n\u003cattr name=\"sb_uncheck_color\" format=\"reference|color\"/\u003e           关闭颜色\n\u003cattr name=\"sb_checked_color\" format=\"reference|color\"/\u003e           开启颜色\n\u003cattr name=\"sb_border_width\" format=\"reference|dimension\"/\u003e        边框宽度\n\u003cattr name=\"sb_checkline_color\" format=\"reference|color\"/\u003e         开启指示器颜色\n\u003cattr name=\"sb_checkline_width\" format=\"reference|dimension\"/\u003e     开启指示器线宽\n\u003cattr name=\"sb_uncheckcircle_color\" format=\"reference|color\"/\u003e     关闭指示器颜色\n\u003cattr name=\"sb_uncheckcircle_width\" format=\"reference|dimension\"/\u003e 关闭指示器线宽\n\u003cattr name=\"sb_uncheckcircle_radius\" format=\"reference|dimension\"/\u003e关闭指示器半径\n\u003cattr name=\"sb_checked\" format=\"reference|boolean\"/\u003e               是否选中\n\u003cattr name=\"sb_shadow_effect\" format=\"reference|boolean\"/\u003e         是否启用阴影\n\u003cattr name=\"sb_effect_duration\" format=\"reference|integer\"/\u003e       动画时间，默认300ms\n\u003cattr name=\"sb_button_color\" format=\"reference|color\"/\u003e            按钮颜色\n\u003cattr name=\"sb_show_indicator\" format=\"reference|boolean\"/\u003e        是否显示指示器，默认true：显示\n\u003cattr name=\"sb_background\" format=\"reference|color\"/\u003e              背景色，默认白色\n\u003cattr name=\"sb_enable_effect\" format=\"reference|boolean\"/\u003e         是否启用特效，默认true\n```\n\n\nScreenShot\n-------\n\u003ca href=\"https://github.com/zcweng/SwitchButton/blob/master/sample/sample-debug.apk\"\u003eSample Apk:\u003c/a\u003e\u003cbr\u003e\n![](http://qr.api.cli.im/qr?data=https%253A%252F%252Fgithub.com%252Fzcweng%252FSwitchButton%252Fblob%252Fmaster%252Fsample%252Fsample-debug.apk\u0026level=H\u0026transparent=false\u0026bgcolor=%23ffffff\u0026forecolor=%23000000\u0026blockpixel=12\u0026marginblock=1\u0026logourl=\u0026size=280\u0026kid=cliim\u0026key=8144f9f150d38d7d364c923d0b9c87cf)\u003cbr\u003e\n\n\nLicense\n-------\nMIT, See the \u003ca href=\"https://github.com/zcweng/SwitchButton/blob/master/LICENSE\"\u003e[LICENSE]\u003c/a\u003e file for details.\n","funding_links":[],"categories":["SwitchButton","Kotlin"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzcweng%2FSwitchButton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzcweng%2FSwitchButton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzcweng%2FSwitchButton/lists"}