How to disable Material Slider Widget

2.9k Views Asked by At

I'm using Slider Widget from google Material library and I need to prevent user from slide the widget for a while. Is there any way to do that? (I prefer to not using onPositionChanged() method)


<com.google.android.material.slider.Slider
        android:id="@+id/speakerVolumeBottomSheetSeekbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/SliderMaterialTheme"
        app:labelBehavior="gone"
        android:value="0.5"
        app:thumbColor="@color/colorAccent"
        app:trackColorActive="@color/colorAccent"
        app:trackColorInactive="@color/white_22_opacity" />

1

There are 1 best solutions below

0
On BEST ANSWER

Use:

   <com.google.android.material.slider.Slider
        android:enabled="false"/>

or programmatically:

slider.isEnabled = false