Flexible switch is a responsive switch with some nice features which developers can use for making awesome switches on android platform.

Overview

flexible-switch

It is a responsive switch in android, it can resize itself according to its size. It's recommended to use it with ConstraintLayout to get better result.

Screenrecorder-2022-08-27-15-36-12-387.mp4

USAGE

Just add FlexibleSwitch in your layout XML and flexible-switch library in your project via Gradle:

allprojects {
    repositories {
    ...
    maven { url 'https://jitpack.io' }
    ...
  }
}
dependencies {
  implementation 'com.github.codersrouteandroid:flexible-switch:1.0'
}

XML

<com.codersroute.flexiblewidgets.FlexibleSwitch
            android:layout_width="200dp"
            android:layout_height="100dp"
            android:layout_marginTop="20dp"
            android:layout_marginBottom="20dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_gravity="center"
            android:textSize="15sp"
            app:backgroundColorOnSwitchOn="#827717"
            app:backgroundColorOnSwitchOff="#4A148C"
            app:thumbColorOnSwitchOff="#FFFFFF"
            app:showText="true"
            android:checked="false"
            app:thumbColorOnSwitchOn="#4A148C"
            app:strokeColorOnSwitchOn="#827717"
            app:strokeColorOnSwitchOff="#827717"
            app:textColorOnSwitchOff="@color/white"
            app:textColorOnSwitchOn="#4A148C"
            />

An example activity is in this project to show all the functionalities of this switch, for more information check out this video below:

flexible_switch_example.mp4

Use these following properties in your XML to change your FlexibleSwitch.

Properties:
  • android:checked To change (on/off) status
  • app:backgroundColorOnSwitchOn To change background color of switch when switch is on
  • app:backgroundColorOnSwitchOff To change background color of switch when switch is off
  • app:thumbColorOnSwitchOn To change thumb color of switch when switch is on
  • app:thumbColorOnSwitchOff To change thumb color of switch when switch is off
  • app:strokeColorOnSwitchOn To change stroke border color of switch when switch is on
  • app:strokeColorOnSwitchOff To change stroke border of switch when switch is off
  • app:textColorOnSwitchOn To change text color of switch when switch is on
  • app:textColorOnSwitchOff To change text color of switch when switch is off
  • app:speed To change speed of animation
  • app:strokeWidth To change size of stroke border
  • app:showText To turn on or off text visibility
  • android:fontFamily To change typeface of status text of switch
  • app:textOn To change status text when switch is on
  • app:textOff To change status text when switch is off

Java

 flexibleSwitch.addOnStatusChangedListener(new FlexibleSwitch.OnStatusChangedListener() {
            @Override
            public void onStatusChanged(boolean b) {
                
            }
        });
You might also like...
A tip app which the user can use a screen bar to choose a tip based on the service, the total is then displayed.

Tip Calculator Spencer Damon Tippy Total computes the tip and total amount for a bill. The app uses the base amount and tip percentage to calculate th

Droidup - Simple, flexible app self-updater for Android

Droidup - Simple, flexible app self-updater for Android

Kotrlin Programming Language Cross-Platform Development which includes Android, iOS and Backend. Pretty much everwhere.
Kotrlin Programming Language Cross-Platform Development which includes Android, iOS and Backend. Pretty much everwhere.

Kotlin-Everywhere: Kotlin Programming Language Cross-Platform Development This is still a WIP but the idea is to create a tiny KOTLIN project that cou

An e-commerce app which provide a new platform to order food items from various restaurants
An e-commerce app which provide a new platform to order food items from various restaurants

Food_App_Internshala An e-commerce app which provide a new platform to order food items from various restaurants. Splash and Login Page Opening of the

An library to help android developers working easly with activities and fragments (Kotlin version)
An library to help android developers working easly with activities and fragments (Kotlin version)

AFM An library to help android developer working easly with activities and fragments (Kotlin) Motivation Accelerate the process and abstract the logic

Screenshot Kata for Android Developers with Kotlin. The main goal is to practice UI Screenshot Testing.
Screenshot Kata for Android Developers with Kotlin. The main goal is to practice UI Screenshot Testing.

KataScreenshot in Kotlin We are here to practice UI testing using screenshot tests for Android. We are going to use Espresso to interact with the Appl

Super Heroes Kata for Android Developers in Kotlin. The main goal is to practice UI Testing.
Super Heroes Kata for Android Developers in Kotlin. The main goal is to practice UI Testing.

KataSuperHeroes in Kotlin We are here to practice UI Testing. We are going to use Espresso to interact with the Application UI. We are going to use Ko

Maxibon kata for Kotlin Developers. The main goal is to practice property based testing.
Maxibon kata for Kotlin Developers. The main goal is to practice property based testing.

Kata Maxibon for Kotlin. We are here to practice property based testing. We are going to use KotlinTest to write our tests. We are going to practice p

TODO API Client Kata for Kotlin Developers. The main goal is to practice integration testing using MockWebServer
TODO API Client Kata for Kotlin Developers. The main goal is to practice integration testing using MockWebServer

KataTODOApiClient for Kotlin We are here to practice integration testsing using HTTP stubbing. We are going to use MockWebServer to simulate a HTTP se

Releases(1.0)
Owner
Coders Route
Coders Route only focuses on building user friendly games and widgets. We try our best to make our users happy.
Coders Route
An application with the use of Kotlin can change the color of the text, and the background with the press of a button and switch.

An application with the use of Kotlin can change the color of the text, and the background with the press of a button and switch.

Robert Velasquez 2 Jul 20, 2022
The home of the amigo-platform which serves as the main service for the amigo multimedia platform

amigo-platform This is the home of the amigo-platform which serves as the main service for the amigo multimedia platform. Authentication with JWT Toke

null 1 Nov 22, 2021
Android Multi Theme Switch Library ,use kotlin language ,coroutine ,and so on ...

Magic Mistletoe Android多主题(换肤)切换框架 背景 时隔四年,在网易换肤之前的思路下,做了几点改进,现在完全通过反射创建View,并且在SkinLoadManager中提供一个configCustomAttrs以支持自定义View的属性插队替换 摈弃了之前的AsyncTask

Mistletoe 18 Jun 17, 2022
A sample skeleton backend app built using Spring Boot kotlin, Expedia Kotlin Graphql, Reactive Web that can be deployed to Google App Engine Flexible environmennt

spring-kotlin-gql-gae This is a sample skeleton of a backend app that was built using: Spring Boot(Kotlin) Reactive Web Sprinng Data R2DBC with MYSQL

Dario Mungoi 7 Sep 17, 2022
Provides Ktor Server libs for building awesome Kotlin plugins which needs to provide builtin HTTP servers

Ktor Plugin Provides Ktor Server libs for building awesome Kotlin plugins which needs to provide builtin HTTP servers. Requires: https://github.com/Po

null 0 Nov 13, 2021
Nice and simple DSL for Espresso Compose UI testing in Kotlin

Kakao Compose Nice and simple DSL for Espresso Compose in Kotlin Benefits Readability Reusability Extensible DSL How to use it Create Screen Create yo

null 66 Sep 14, 2022
Nice String in Kotlin

Nice String We'll say a string is nice if at least two of the following conditio

Bunyod Rafikov 0 Dec 28, 2021
Xoxo is a simple wrapper around org.w3c.dom to parse XML using nice Kotlin APIs

Xoxo ?? Xoxo is a simple wrapper around org.w3c.dom to parse XML using nice Kotlin APIs. No more NodeList, .item(), etc... just use .children, .filter

Martin Bonnin 51 Sep 1, 2022
Helper functions for making Approvals-Java more Kotlin friendly

Approvals-Kt Helper functions for making Approvals-Java more Kotlin-friendly Usage Verify using Approvals-Kt import com.github.greghynds.approvals.Kot

Greg Hynds 2 Oct 18, 2021
A very simple Android app which shows you random memes with the help of meme-api which you can share with your friends!

Meme Share A very simple Android app which shows you random memes with the help of meme-api which you can share with your friends! Tech stack 100% wri

Stɑrry Shivɑm 8 Aug 10, 2022