0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Composeサイズの違うテキストの下部を揃える方法

Posted at

Composeでサイズの違うテキストの下部を揃える方法です。
ポイントアプリなので、数字のポイントと単位でサイズが違うけど位置が揃っているデザインなどがあったりします。
その時に便利な方法です。

スクリーンショット 2023-11-05 16.18.40.png

TextSample.kt
@Composable
fun TextSample() {
    Row {
        Text(
            text = "1000",
            modifier = Modifier.alignByBaseline(),
            maxLines = 1,
            fontSize = 25.sp
        )
        Text(
            text = "P",
            modifier = Modifier.alignByBaseline(),
            maxLines = 1,
            fontSize = 10.sp
        )
    }
}

alignByBaseline()を設定するといい感じに揃えてくれます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?