Reputation: 53
This is how I want to show the value of the slider. Please find the picture
Upvotes: 3
Views: 3303
Reputation: 51
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"
/>
Upvotes: 3
Reputation: 44861
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 visibleYou can find the code here with the extensive javadoc explanation.
You could open a feature request for this on the Material GitHub issues page
Upvotes: 2