Status Update
Comments
ra...@gmail.com <ra...@gmail.com> #2
Use cases: Some phone(like OnePlus) will change the density when rotating the screen or enter PIP mode, I use slider to make a controller for a video player app, at this point the video is playing and the progress bar is changing, then App will be crashed
sg...@google.com <sg...@google.com>
ma...@google.com <ma...@google.com> #3
Not sure I understand the use case.
Slider cannot measure 0.dp it has to measure at least 2 thumbs so that the thumb can move from 0f to 1f. Do you mean to use Modifier.weight instead so that it takes the available space?
ra...@gmail.com <ra...@gmail.com> #4
yes, i am using Modifier.weight for Slider, i don't know why it crash on OnePlus phone
ra...@gmail.com <ra...@gmail.com> #5
Here is a example code of my slider controller
Row(Modifier.fillMaxWidth()) {
// Some icon buttons here
Slider(
modifier = Modifier.weight(1f)
//...
}
// Other icon buttons here
}
When exiting the horizontal screen state or entering the picture-in-picture mode, the above exception will be caused, and it only happens on OnePlus phone
ma...@google.com <ma...@google.com> #6
Thanks I'll add a fix for parents with width 0.dp maybe it something that only happens briefly and then it measures something reasonable. Can you share the exact model/OS?
ra...@gmail.com <ra...@gmail.com> #7
OnePlus 7/OnePlus 8
I don't have any specific phone to test,it's the feedback from my users. After the simulator test, I guess it's the change of density?
At present, I use BoxWithConstraints to wrap the Slider. And check the maximum width of the constraint, and it will only be displayed when the maximum width is above 40dp, which temporarily fixes the exception.
ap...@google.com <ap...@google.com> #8
Branch: androidx-main
commit 76f24353f136570d95e80840a44d6faf67383971
Author: Mariano Martin <marianomartin@google.com>
Date: Tue May 10 16:01:23 2022
Allow slider parent to have 0 width
Fix: 231707291
Test: added slider_zero_width
Change-Id: Idb144788fd8e45dd651d211c8093fc53be39a0d1
M compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/Slider.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Slider.kt
M compose/material3/material3/src/androidAndroidTest/kotlin/androidx/compose/material3/SliderTest.kt
Description
Jetpack Compose version: 1.2.0-alpha07 Jetpack Compose component used: material3
Use Slider with zero width constrants, then change the density, the Slider might causes app crash:
Here is a simple code to reproduce that:
Just drag the slider, it will crash very soon