This is how I want to show the value of the slider. Please find the picture
Asked
Active
Viewed 1,977 times
2
-
Currently there is no public API to show Slider label always visible. One possible solution for now is using a Reflection check this: https://stackoverflow.com/questions/68613186/material-slider-and-range-slider-tooltip-not-always-visible/68711632#68711632 – MariosP Sep 02 '21 at 08:24
2 Answers
2
This is currently not supported, the available options in LabelFormatter
(which can be applied to sliders with slider.setLabelFormatter(...)
are:
LabelFormatter.LABEL_FLOATING
: Label visible during interaction onlyLabelFormatter.LABEL_WITHIN_BOUNDS
: Label visible during interaction onlyLabelFormatter.LABEL_GONE
: Label never visible
You can find the code here with the extensive javadoc explanation.
You could open a feature request for this on the Material GitHub issues page

MatPag
- 41,742
- 14
- 105
- 114
1
You can set the label behaviour "visible" in the XML file. So in the slider XML code, you just need to add
app:labelBehavior="visible"
Below I am attaching a sample XML code for the same.
<com.google.android.material.slider.Slider
android:id="@+id/seek_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:valueFrom="1"
android:valueTo="100"
android:layout_gravity="center"
android:layout_margin="15dp"
app:tickColor="#0000FF"
app:labelStyle="@style/Tooltip"
app:labelBehavior="visible"
/>

Aatman Vaidya
- 41
- 7