Skip to content
李涛 edited this page Aug 4, 2024 · 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 Sample


  1. WeRead Style

    View Sample


  1. Color Pick Style

    View Sample


  1. Custom Thumb Drawable Style

    View Sample


  1. Lottie Animation style

    View Sample


  1. Tiktok Style

    View Sample


  1. BiliBili Style

    View Sample


  1. YouTube video preview style

    View Sample


  1. YouTube graph style

    View Sample


  1. Effect with issues #13

    View Sample


  1. Vertical Mode

    View Sample


Clone this wiki locally