'How to get the value from slider in other format?
currently my slider looks like this 
I want to change the number of current position in a format without decimal place. So in this case it should show me 27 instead of 0.2731...
here is my Code
@Composable
fun Slider() {
var sliderPosition by remember { mutableStateOf(0f) }
Slider(value = sliderPosition,
onValueChange = { sliderPosition = it })
Text(text = sliderPosition.toString())
}
Solution 1:[1]
Slider has a valueRange paremeter which is valueRange: ClosedFloatingPointRange<Float> = 0f..1f by default, you can change it as
valueRange = 0f..100f or valueRange = 0f..360f or any closed range of your choosing
Slider(
value = sliderPosition,
onValueChange = { sliderPosition = it},
valueRange = 0f..100f
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
