Skip to content

About

A light toggle view for Android in Kotlin, acts like ios toggle style.

Resources

Stars

1 star

Watchers

1 watching

Forks

 
 

Repository files navigation

EasyToggle

( 我爱中文 )

A light toggle view for Android in Kotlin, with only 1 file, it acts like ios toggle style in default settings, also you can design it using all the given attributes. The toggle view acts differently while touching different ranges around the button, it performs good experience for user.

ScreenShots

easytoggle

Usage

Add to your root build.gradle:

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

Add the dependency:

dependencies {
    compile 'com.github.huzenan:EasyToggle:v1.0.0'
}

layout

The layout is very simple, if you want exactly a ios style toggle, nothing need to be set in your layout file.

    <com.hzn.lib.EasyToggle
        android:id="@+id/et"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

Activity

Using lambda, setting the listener is also very easy.

    et.setOnToggledListener {
        tv.text = if (it) "on" else "off"
    }

Attributes

name description
etLength button extensional length(without raidus)
etRadius radius of the button
etRange range that changes the acting of the toggle view
etBgOffColor background color when off
etBgOnColor background color when on
etBgStrokeWidth background stroke width
etBgTopColor color above the backgroud
etButtonColor color of the button
etButtonStrokeColor color of stroke of the button
etButtonStrokeWidth stroke width of the button
etShadowOffsetY offsetY of shadow, greater than 0

About

A light toggle view for Android in Kotlin, acts like ios toggle style.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages