Leafzlf / nifty-slider

:star: Sliders allow users to make selections from a range of values. :star:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

banner

NiftySliderVersion License API查看文档 | English

开始

  1. 添加依赖
dependencies {

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

    // 自定义交互效果 (非必选功能)
    implementation 'io.github.litao0621:nifty-slider-effect:(latest version)'

}
  1. 添加布局文件
    <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. 注册滑动回调
        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
            }

        })

自定义滑动效果

1. M3 Style

查看样例

2. 微信阅读菜单中滑动条样式

查看样例

3. 颜色选择器

查看样例

4. 自定义滑块

查看样例

5. 结合lottie动画自定义滑块

查看样例

6. 抖音滑动条样式

查看样例

7. BiliBili滑动条样式

查看样例

8. YouTube拖动视频预览样式

查看样例

9. YouTube展示用户关注度样式

查看样例

参与项目

欢迎共同完善项目,有问题随时提交Issues

捐赠

如果你觉的这个库帮到了你的话可以点击Star按钮来支持作者,也可以请作者喝杯咖啡,非常感谢!:smiley:

DEMO

Demo APK 下载地址1

Demo APK 下载地址2

License

Copyright 2023 litao

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

:star: Sliders allow users to make selections from a range of values. :star:

License:Apache License 2.0


Languages

Language:Kotlin 99.8%Language:Shell 0.2%