I'd like to place a Text with style of a given pix...
# compose
t
I'd like to place a Text with style of a given pixel size (fittedStyle), at the baseline of a style of a different size (style). My cheesy approach to accomplishing this is:
Copy code
Row(modifier = heightMod) {
    // wish there was a simpler way to do this,
    // put in a dummy (0 width) text with the full height style, and then baseline align our fitted text to it
    // alignByBaseline is only available in a Row
    // I wish I could just interrogate the line height info directly from the style and then do the baseline adjust there
    Text("", style = style, modifier = Modifier.alignByBaseline())
    Text(
       text = text,
       modifier = Modifier.alignByBaseline(),
       style = fittedStyle,
       overflow = fittedOverflow,
       softWrap = false,
       maxLines = 1
    )
}
The inline comments pretty much asks the question. Is there not a more simply way to do this? I'd rather wrap it in a box and add an offset than have to generate a dummy entry.
k
TextMeasurer
would give you a
TextLayoutResult
with
firstBaseline
t
Thanks! That did just the trick. I've finally got me a working AutoSizeLabel that fits my needs.
👍 1