[Adaptive] HorizontalTwoPaneStrategy does not split equally with splitFraction 0.5
ammargitham opened this issue · 3 comments
Description
When using TwoPane
with HorizontalTwoPaneStrategy(splitFraction = 0.5f)
, the first and the second composables do not have equal width.
Steps to reproduce
Code:
var panelASize by remember {
mutableStateOf(IntSize.Zero)
}
var panelBSize by remember {
mutableStateOf(IntSize.Zero)
}
TwoPane(
first = {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Yellow)
.onSizeChanged { panelASize = it }
) {
Text(
modifier = Modifier.align(Alignment.Center),
text = "Panel A\n${panelASize.width}",
style = MaterialTheme.typography.displayLarge,
)
}
},
second = {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Cyan)
.onSizeChanged { panelBSize = it }
) {
Text(
modifier = Modifier.align(Alignment.Center),
text = "Panel B\n${panelBSize.width}",
style = MaterialTheme.typography.displayLarge,
)
}
},
strategy = HorizontalTwoPaneStrategy(splitFraction = 0.5f),
displayFeatures = calculateDisplayFeatures(activity = this@MainActivity),
foldAwareConfiguration = FoldAwareConfiguration.VerticalFoldsOnly,
)
Expected behavior
Expected widths of Panel A and B to be equal.
Screenshots:
Have you been able to reproduce this on a physical device?
Sorry, I don't own any tablet or foldable. So can't test on a real device.
I was able to reproduce that behavior on the resizable emulator with the following steps:
- Open the resizable emulator
- Toggle to the "Foldable" configuration. This causes the list of the display features to include the folding feature for the foldable.
- Toggle to the "Tablet" configuration. This doesn't remove the folding feature, so the old folding feature at x = 884 is still incorrectly present in the tablet configuration.
- The (erroneous) vertical fold is automatically avoided by the
TwoPane
logic, which leads to the unexpected sizing in the screenshot above
Reported that issue here: https://issuetracker.google.com/issues/295909182
I couldn't repro on the Pixel Fold emulator, but my Pixel Fold emulator right now is not reporting any folding features at all. 🙃
I'm going to close this here in accompanist as I suspect the issues here lie upstream in the emulator configuration, where erroneous folding features are causing unintuitive behavior.