Hi everyone. Unfortunatelly I don´t know why my ba...
# compose
b
Hi everyone. Unfortunatelly I don´t know why my baseline alignement for text elements in different rows is not working 😞
Copy code
Row {
  Row(
    modifier = Modifier
      .alignByBaseline(),
  ) {
    Text(
      text = "90",
      style = MaterialTheme.typography.headlineMedium.merge(
        other = TextStyle(
          lineHeightStyle = LineHeightStyle(
            <http://LineHeightStyle.Alignment.Top|LineHeightStyle.Alignment.Top>,
            Trim.None,
          ),
        ),
      ),
    )

    Text(
      text = "+4",
      style = MaterialTheme.typography.labelLarge,
      modifier = Modifier.offset { IntOffset(0, -2) },
    )
  }

  Text(
    text = " should be aligned to baseline of \"90\"",
    color = Color.Red,
    modifier = Modifier
      .alignByBaseline(),
    style = MaterialTheme.typography.bodyLarge,
  )
}
currently it looks like in the screenshot. but the red text should be basealigned to the big "90" can you please tell me how i can fix this. thx
a
Modifier.alignByBaseline()
must be applied to the `Text`s, not the
Row
.
b
@Albert Chang Thx for the fast answer but it is also not working if i remove it from the row and add it to the text "90". then it looks like this:
a
Okay I see the problem now. You can apply
Modifier.alignBy(LastBaseline)
to the
Row
.
b
@Albert Chang thx a lot