Denis
02/08/2021, 4:37 PMjava.lang.IllegalArgumentException: Layer is redrawn for LayoutNode in state NeedsRelayout [LayoutNode@5aef729 children: 0 measureBlocks: MeasuringIntrinsicsMeasureBlocks@d83eaae{ measureBlock=androidx.compose.foundation.layout.BoxKt$boxMeasureBlocks$1@340204f }]
There was a similar issue https://github.com/android/compose-samples/issues/129. I don't know if it's the same problem.class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
var dark by remember { mutableStateOf(false) }
ExperimentsTheme(darkTheme = dark) {
Surface(color = MaterialTheme.colors.background) {
ListItemsApp(dark, setDark = { dark = it })
}
}
}
}
}
@Composable
fun ListItemsApp(dark: Boolean, setDark: (Boolean) -> Unit) {
LazyColumn {
val paddingModifier = Modifier.padding(bottom = 8.dp)
item {
ListItem(
modifier = Modifier.clickable(onClick = { setDark(false) }),
trailing = { RadioButton(selected = !dark, onClick = { setDark(false) }) },
text = { Text("Light") },
)
ListItem(
modifier = Modifier.clickable(onClick = { setDark(true) }),
trailing = { RadioButton(selected = dark, onClick = { setDark(true) }) },
text = { Text("Dark") },
)
Divider()
}
for (i in (1..7)) {
item {
Text(
"Block $i",
modifier = Modifier.padding(16.dp),
style = MaterialTheme.typography.subtitle1
)
ListItem(
text = { Text("$i. List item with switch") },
secondaryText = { Text("Short secondary text") },
trailing = { Switch(checked = i % 4 == 0, onCheckedChange = {}) },
)
ListItem(
text = { Text("$i. List item with radio button") },
secondaryText = {
Text(
"Somewhat long secondary text that may wrap on the second line, but I'm not sure about that",
modifier = paddingModifier
)
},
)
}
}
}
}
paddingModifier
. I'd rather not add it, but without it ListItem
with a long secondary text doesn't have enough bottom padding. And if I add padding to a whole ListItem, the ripple does not get drawn on that padding. I know about singleLineSecondaryText
, but how do I know if the text is too long?compose_version = '1.0.0-alpha11'
classpath 'com.android.tools.build:gradle:7.0.0-alpha05'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21-2"
Andrey Kulikov
02/09/2021, 12:14 AMDenis
02/10/2021, 5:43 PMpaddingModifier
. But with singleLineSecondaryText = false
for some of `ListItem`s.item
in a Column
, the exception is gone