mattinger
02/08/2022, 5:43 PMAlbert Chang
02/08/2022, 6:24 PMonTextLayout
parameter of Text
. Note that you need a custom layout to place the icon according to the line count of the text.mattinger
02/08/2022, 6:40 PMval numberOfHeadlineLines = remember { mutableStateOf(0) }
val numberOfBodyLines = remember { mutableStateOf(0) }
val iconAlignment = derivedStateOf {
if (numberOfBodyLines.value + numberOfHeadlineLines.value >= 3) {
<http://Alignment.Top|Alignment.Top>
} else {
Alignment.CenterVertically
}
}
This is causes the icon to start center aligned and then jump to the top. It makes sense that it does since it’s state and it’s going to lay things out, display it, and then recompose when the value of iconAlignment is set. I’m not sure i can do anything about that, and it’s a red flag i’ve given to our UX about this requirementAlbert Chang
02/08/2022, 7:05 PM