Adrian Landborn
06/08/2021, 7:08 AMCheckbox is 24x24dp which is no-no, needs to be at least 48x48dp to pass the checks. So my approach is to combine Checkbox with Text to increase the width and add som internal padding to fix the height. Also add the same onClick on both items. But this does not work. Any advice? As soon as I add any padding, the mergeDescendants stops working. Is it a bug?
var checkedState by remember { mutableStateOf(false) }
Row(
Modifier
.clickable { checkedState = !checkedState }
.semantics(mergeDescendants = true) {}
.padding(top = 12.dp, bottom = 12.dp)
) {
Checkbox(
checked = checkedState,
onCheckedChange = { checkedState = !checkedState })
Text(text = "Some label", modifier = Modifier.padding(start = 8.dp))Adrian Landborn
06/09/2021, 9:26 AMonCheckedChange completely from the checkbox and only kept it on the row. I also changed clickable to toggleable . Used minSize and center vertically to get the position right.
Here is the code.
Row(modifier
.semantics(mergeDescendants = true) {
toggleableState = ToggleableState(checked)
stateDescription
}
.toggleable(
value = checked,
enabled = enabled,
role = Role.Checkbox
) { onCheckedChange.invoke(checked) }
.padding(start = space75)
.defaultMinSize(space300, space300)
)
{
Checkbox(
checked = checked,
onCheckedChange = null,
interactionSource = interactionSource,
enabled = enabled,
colors = if (error) CheckboxStyle.Error.colors() else style.colors(),
modifier = Modifier.align(Alignment.CenterVertically)
)
SpacerH(space100)
Text(text = label, modifier = Modifier.align(Alignment.CenterVertically).padding(end = space75))
}Adrian Landborn
06/09/2021, 9:32 AMBryan Herbst
06/09/2021, 1:30 PMtoggleable() Modifier in your most recent code snippet- it will do a mergeDescendants and add the toggleableState semantics for you. With that configuration my checkbox rows with text are correctly reading out checked/unchecked!Adrian Landborn
06/09/2021, 1:50 PMandroidx.compose.material.Checkbox(checked = false, onCheckedChange = {})Bryan Herbst
06/09/2021, 1:56 PMRow with a toggleable() Modifier?Adrian Landborn
06/09/2021, 2:01 PMAdrian Landborn
06/09/2021, 2:03 PMBryan Herbst
06/09/2021, 2:17 PMCheckbox.
I’d file a bug on the issue tracker: https://issuetracker.google.com/issues/new?component=612128Adrian Landborn
06/09/2021, 2:18 PMBryan Herbst
06/09/2021, 2:19 PMAdrian Landborn
06/09/2021, 2:19 PMAdrian Landborn
06/09/2021, 2:20 PMAdrian Landborn
06/09/2021, 2:21 PMAdrian Landborn
06/09/2021, 2:45 PMBryan Herbst
06/09/2021, 2:59 PMAdrian Landborn
06/09/2021, 7:41 PMAdrian Landborn
06/29/2021, 6:52 AMJulianK
06/29/2021, 8:54 AMAdrian Landborn
06/29/2021, 11:52 AM