Skip to content

pocket7878/switcherView

Repository files navigation

SwitcherView

Toggle Switch Like UI component for Android.

Switcher View Example

Usage

Install

Add maven repository into your build.gradle:

repositories {
    ...
    jcenter()
    ...
}

Add dependency into your application-level build.gradle

dependencies {
    ...
    implementation "jp.pocket7878.switcherview:switcherview:1.0.2"
    ...
}

Add view into your layout:

<jp.pocket7878.switcherview.SwitcherView
    app:sv_background_color="@color/white"
    app:sv_leftmost_hover_color="@color/primary"
    app:sv_rightmost_hover_color="@color/alert"
    app:sv_left_choice_icon_src="@drawable/ic_good"
    app:sv_left_choice_text="@string/switcher_good_text"
    app:sv_right_choice_icon_src="@drawable/ic_discontent"
    app:sv_right_choice_text="@string/switcher_discontent_text"
    app:sv_disable_choice_tint_color="@color/icon_default"
    app:sv_enable_choice_tint_color="@color/white"
    />

Layout Attributes

Attributes guide image

API

  • switchToLeftChoice() : Select left choice programatically.
  • switchToRightChoice() : Select right choice programatically.
  • setOnSwitchSelectChangeListener
    • onLeftChoiceSelected()
    • onRightChoiceSelected()
    • onStartSwitchUserControl() : Called when user start interact with hover.
    • onFinishSwitchUserControl() : Called when user finish interact with hover.

About

Toggle Switch Like UI component for Android.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages