AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard switch component.

Overview

AwesomeSwitch Download

AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard switch component.

gif of AwesomeSwitch in use

Adding to project

Gradle

Add below code to your root build.gradle file (if you have multiple modules and only one of them require AwesomeSwitch, add the jcenter() repository only in that module's build.gradle).

allprojects {
    repositories {
        jcenter()
    }
}

And add the following dependency code to your module's build.gradle file.

dependencies {
    implementation "ss.anoop:awesome-switch:${latest-version}"
}

AwesomeSWitch can be included in your layout xml like any other view. Below is a simple example

Usage

<ss.anoop.awesomeswitch.AwesomeSwitch
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:radius="12dp"
    app:checkedColor="#53e079"
    app:backgroundColor="#000"
    app:checkedBackgroundColor="#53e079"
/>

Customization

Table below descripes the properties available to customize the AwesomeSwitch

Property Name Format Description
radius dimension Defines the size of the circle in the AwesomeSwitch
checkedColor color defines the color of the circle when the switch is in checked (on) state. Default color is white. If checked and unchecked(off) have different colors, there will be color transition animation when states change
uncheckedColor color defines the color of the circle when the switch is in unchecked (off) state. Default color is white. If checked(on) and unchecked have different colors, there will be color transition animation when states change
backgroundColor color defines the color of the switch background shape. The same will be used for checked and unchecked state unless checkedBackgroundColor is mentioned
checkedBackgroundColor color defines the color of the switch background shape in checked(on) state.
innerPadding dimension defines the padding applied to the background shape, ie, the space between the circle and the background shape
isChecked boolean to set the state to checked(on) or unchecked(off) at the time of inflation. Default value of this field is false
animationDuration integer defines the duration of unchecked to checked or the opposite animation duration in milliseconds. By default it is 300 milliseconds

Change Listener

AwesomeSwitch offers an OnCheckedListener that informs when checked state is changed. The callback has a boolean field which indicates checked(on) state when value is true, false indicates unchecked(off) state.

awesomeSwitch.setOnCheckedListener { state -> processState(state) }

Find this library useful? ❤️

Support it by joining stargazers for this repository. ⭐

License

Copyright 2019 anoop44 (Anoop)

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.
You might also like...
Base on android-process-button this is the advanced version of the android-process-button.
Base on android-process-button this is the advanced version of the android-process-button.

Rock Button release log Base on android-process-button this is the advanced version of the android-process-button ##Main Features ActionProcessButton

Android Circular Progress Button
Android Circular Progress Button

🔺 Before using this library, read information below 🔺 This library is not more supported. If you want to add new feature or fix a bug, grab source

Android Buttons With Built-in Progress Meters.
Android Buttons With Built-in Progress Meters.

Description Android Buttons With Built-in Progress Meters. Wiki Home Screenshots User Guide Integration The lib is available on Maven Central, you can

Circle button widget for Android

DEPRECATED This library is deprecated and no new development is taking place. Consider using a FAB(Floating action button) instead. E.g. the Android D

FButton - a flat button library for Android
FButton - a flat button library for Android

FButton FButton is a custom Button of Android with "Flat UI" concept. FButton's design get inspiration from designmono. This library is very small and

Android button which moves in eight direction.
Android button which moves in eight direction.

Moving Button Android button which moves in eight direction. Preview Sample Demo You can download demo movie file here : demo.mov It's also on Youtube

[] Android floating action button
[] Android floating action button

DEPRECATED Use the FloatingActionButton from the support library instead. FloatingActionButton Description Android floating action button which reacts

Floating Action Button for Android based on Material Design specification
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Bootstrap style widgets for Android, with Glyph Icons
Bootstrap style widgets for Android, with Glyph Icons

Android-Bootstrap Android Bootstrap is an Android library which provides custom views styled according to the Twitter Bootstrap Specification. This al

Owner
Anoop S S
A passionate Android Applications Developer.
Anoop S S
A cute widget of Switch Button for you to create beautiful and friendly UI.

SwitchButton To get a quick preview, you can get Demo apk in Google Play or Directly download. This project provides you a convenient way to use and c

kyleduo 4.6k Nov 18, 2022
⭐️ beautiful switch widget with sticky animation ⭐️

StickySwitch StickySwitch library for android this library is beautiful switch widget with sticky animation Requirements Android SDK 15+ Usage Add it

GwonHyeok 768 Nov 10, 2022
Google launcher-style implementation of switch (enable/disable) icon

Android-SwitchIcon Google launcher-style implementation of switch (enable/disable) icon Compatibility This library is compatible from API 15 (Android

Zagumennyi Evgenii 2.3k Nov 18, 2022
comtomize view submit button which you use for submit operation or download operation and so on.

This is library project with a custom view that implements concept of Submit Button (https://dribbble.com/shots/1426764-Submit-Button?list=likes&offse

ZhangLei 129 Feb 5, 2021
A simple Floating Action Button that shows an anchored Navigation View

Floating Navigation View A simple Floating Action Button that shows an anchored Navigation View and was inspired by Menu Material Fixed created by Tom

André Mion 1.3k Nov 18, 2022
Button for android with animations for transition and error states.

Transition Button Android Preview Expand animation: Shake animation: Installation Gradle dependencies { implementation 'com.royrodriguez:transitionbu

Roy Rodriguez 133 Dec 1, 2022
Primitive OpenGL (ES) based graphics library and engine for Android development.

Parrot Primitive OpenGL (ES) based graphics library and engine for Android development. Parrot makes Android core graphics simpler, giving you the fea

null 1 Dec 30, 2021
Materially inspired widgets and views that expose RxJava bindings.

Rx.Widgets Materially inspired widgets and views. Use ExpandableButtonGroup Add the widget to your view: <io.andref.rx.widgets.ExpandableButtonGro

Andrefio 12 Mar 12, 2018
Floating Action Button But Moveable And Expandalbe

MeFab todo add the maven bacge here Floating Action Button but MOVEABLE and EXPA

Hussien Fahmy 4 Nov 11, 2022
➕ An efficient and beaufitul Multi Float action button library based on Twitter implemented in Jetpack Compose 🚀

Multi Float Action Button ➕ An efficient and beaufitul Multi Float action button library based on Twitter implemented in Jetpack Compose ?? Including

Geovani Amaral 8 Oct 15, 2022