Issue
I found a solution for material.Slider with one thumb, but i need the same for range slider. I need get min and max values from slider. How i can get values from range slider with bindingAdapter?
Solution
You can use LiveData
for it. So, your bindingAdapter
is going to look like this.
@BindingAdapter("onChange")
fun bindOnChange(rangeSlider: RangeSlider, onChangeLiveData: MutableLiveData<Float>) {
rangeSlider.addOnChangeListener(RangeSlider.OnChangeListener { _, value, _ ->
onChangeLiveData.postValue(value)
})
}
You can use this as
<com.google.android.material.slider.RangeSlider
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:onChange="@{passYourOnChangeMutableLiveDataHere}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Answered By - OhhhThatVarun
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.