- 添加依赖
dependencies {
implementation 'io.github.litao0621:nifty-slider:(latest version)'
// 自定义交互效果 (非必选功能)
implementation 'io.github.litao0621:nifty-slider-effect:(latest version)'
}
- 添加布局文件
<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"/>
- 注册滑动回调
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
}
})
10. Effect with issues #13
欢迎共同完善项目,有问题随时提交Issues
如果你觉的这个库帮到了你的话可以点击Star按钮来支持作者,也可以请作者喝杯咖啡,非常感谢!:smiley:
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.