Garan Jenkin
12/06/2021, 12:45 PMStepper(
value = curr.value,
onValueChange = { value ->
curr.value = value
Log.i(TAG, "New value: $value")
},
valueRange = 100.0f .. 220.0f,
steps = (220 - 100) / 5 - 1
) {
Aim was to be able to have a range of 100 to 220 and be able to step values by 5.
The part that confused me was the steps
value. Docs say "Step value is calculated as the difference between min and max values divided by steps+1". So, to get the correct step size, I have to subtract one from what I initially thought as the intuitive number of steps ((220 - 100) / 5
). It's no big deal, reading the documentation solved it, just wasn't sure why "steps+1", though I've likely just misunderstood something.yschimke
12/06/2021, 5:22 PMyschimke
12/06/2021, 5:22 PMSteps: Specifies the number of discrete values, evenly distributed between across the whole value range. Must not be negative. If 0, stepper will have only min and max values and no steps in between
yschimke
12/06/2021, 5:22 PMyschimke
12/06/2021, 5:25 PMyschimke
12/06/2021, 5:26 PMSteve Bower [G]
12/06/2021, 5:30 PMGaran Jenkin
12/06/2021, 10:06 PMsteps
as 1, which doesn't make much sense conceptually, as in I don't see in what sense this description has 1 steps. But given the docs, I can calculate it as 1: (10 - 0) / 5 -1Garan Jenkin
12/06/2021, 10:07 PMStepper(
value = curr.value,
onValueChange = { value ->
curr.value = value
Log.i(TAG, "New value: $value")
},
valueRange = 0.0f .. 10.0f,
steps = 1
) {
// Results in stepper that provides 0, 5 and 10
Garan Jenkin
12/06/2021, 10:26 PM