Tash
08/01/2022, 9:42 PMcurrentLines
ever get updated from the onTextLayout
block? Like if you removed everything else.Paul Woitaschek
08/01/2022, 9:44 PMChris Johnson
08/01/2022, 9:57 PMAlex Vanyo
08/01/2022, 10:06 PMIf I run this code in an app, I get extraLines = 1 and it works as I would’ve expected it to.In an app, you will likely see what is displayed in the preview for a single frame, and then on the following frame, you’ll see what you expect. The preview is only showing that first frame, where
currentLines
is 0
.@Preview
@Composable
fun Repro() {
var show by remember { mutableStateOf(false) }
if (show) {
TextRepeatEmptyLines(text = "Hey", lines = 2)
}
LaunchedEffect(Unit) {
delay(1000)
show = true
}
}
That should make the single frame a bit more obvious if you run it on a device, by delaying it 1 second after launchChris Johnson
08/01/2022, 10:21 PMonSizeChanged
. I'm not 100% sure what a layout primitive is. Is it just a Column, Box, Row
?Alex Vanyo
08/01/2022, 10:28 PMColumn
, Box
, Row
and if you need to do something more custom that isn’t supported with those (or a combination), then go a level deeper and use Modifier.layout
or Layout
(custom layouts describes those in detail)Paul Woitaschek
08/02/2022, 7:07 AMAlex Vanyo
08/02/2022, 7:17 PMParagraph
is the utility for measuring the size of text directly.
That’s how maxLines
is implemented:
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]in/androidx/compose/foundation/text/MaxLinesHeightModifier.kt
It should be possible to fork a version of that for minLines
pretty easily?