Skip to content
李涛 edited this page Mar 7, 2023 · 16 revisions

banner

Getting Started

  1. Maven library dependency
dependencies {

    implementation 'io.github.litao0621:nifty-slider:(latest version)'

    // Added effect for Sliders (Optional Features)
    implementation 'io.github.litao0621:nifty-slider-effect:(latest version)'

}

The latest version is: NiftySliderVersion

  1. Add it to the layout file
    <com.litao.slider.NiftySlider
        android:id="@+id/nifty_slider"
        android:layout_width="match_parent"
        android:layout_height="148dp"
        android:padding="16dp"
        android:value="50"
        android:valueFrom="0"
        android:valueTo="100"
        app:trackColor="@color/m3_demo_track_color"
        app:trackColorInactive="@color/m3_demo_track_inactive_color"
        app:thumbColor="@color/m3_demo_thumb_color"
        app:thumbShadowColor="@color/white"
        app:haloColor="@color/m3_demo_halo_color"/>
  1. Registers a callback to be invoked when the slider changes
        binding.niftySlider.setOnValueChangeListener { slider, value, fromUser ->
            //do something with float value
        }

        binding.niftySlider.setOnIntValueChangeListener { slider, value, fromUser ->
            //do something with int value
        }

        binding.niftySlider.setOnSliderTouchListener(object :NiftySlider.OnSliderTouchListener{
            override fun onStartTrackingTouch(slider: NiftySlider) {
                //do something on touch start
            }

            override fun onStopTrackingTouch(slider: NiftySlider) {
                //do something on touch stop
            }

        })

Custom Effects

  1. M3 Style

    View Demo


  1. WeRead Style

    View Demo


  1. Color Pick Style

    View Demo


  1. Custom Thumb Drawable Style

    View Demo


  1. Lottie Animation style

    View Demo


  1. Tiktok Style

    View Demo


Clone this wiki locally