https://kotlinlang.org logo
#compose
Title
# compose
s

sindrenm

02/01/2022, 2:30 PM
I can't seem to be able to set a proper
weight(1f)
on a
RangeSlider
. Am I doing something funny, or is this a bug with the component?
Copy code
@Preview
@Composable
fun RangeSliderTest() {
    var values by remember { mutableStateOf(0f..1f) }

    Row(
        modifier = Modifier.background(Color.White).fillMaxWidth().padding(16.dp),
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.spacedBy(16.dp),
    ) {
        Text("0")
        RangeSlider(
            modifier = Modifier.weight(1f),
            values = values,
            valueRange = 0f..1f,
            onValueChange = { values = it },
        )
        Text("1")
    }
}
k

Kirill Grouchnikov

02/01/2022, 2:37 PM
Comment on https://issuetracker.google.com/issues/216912877?pli=1 says it should work, so attach your code snippet and screenshot there
s

sindrenm

02/01/2022, 2:40 PM
Oh, thanks! 🙌
y

Yann Badoual

02/01/2022, 2:40 PM
Use
weight(1f, fill = false)
it should work
s

sindrenm

02/01/2022, 2:41 PM
That seems to have no effect, either. I'll post in the issue tracker. 👍
Oh, that seems to work for the regular
Slider
, but not for
RangeSlider
, apparently. 🤔
blob thinking upside down 2
And there's a separate issue for the
RangeSlider
at https://issuetracker.google.com/issues/210289161.