Git Product home page Git Product logo

revealswitch's Introduction

RevealSwitch

Android Arsenal

This library provides you cool reveal animation on toggle.

g_20181001_0205015

Dependency

Step 1: Add Jitpack repository to your root(project) build.gradle at the end of repositories.

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2: Add gradle dependency to your module's build.gradle.

dependencies {
  implementation 'com.github.Akashkamble:RevealSwitch:1.0.1'
}

Usage

Add RevealSwitch to your layout like file like this

<com.akash.RevealSwitch
  android:id="@+id/revealSwitch"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  .../>

To add the toggleListener add following code

switch.setToggleListener(object : OnToggleListener{
    override fun onToggle(isEnable: Boolean) {
       Log.e("TAG","isEnabled ? $isEnable")
    }
 })

To change color of enabled track (default color #444444)

screenshot_20181001-013416-02

Add this in xml

app:setEnabledTrackColor="#FF1744"

Add this in Kotlin or Java

switch.setEnabledTrackColor(Color.parseColor("#FF1744"))

To changle color of disabled track (default colot #FFFFFF)

screenshot_20181001-014628-01

Add this in xml

app:setDisabledTrackColor="#FFFFFF"

Add this in Kotlin or Java

 switch.setDisabledTrackColor(Color.parseColor("#FFFFFF"))

To add the animation duration (default 500ms)

Add this line in xml

app:setAnimationDuration="700"

Add this in Kotlin or Java

switch.setAnimationDuration(700) //Accepts value between 500ms to 1500ms

Added in version 1.0.1

To show the border (default false)

Add this line in your layout file.

app:showBorder="true"

Default border color will be thumb color.

To set borer color

Add this line in xml

app:borderColor="#FF1744"

revealswitch's People

Contributors

akashkamble avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.