小编haa*_*art的帖子

Jetpack Compose - 如何在 ClickableText 中将文本居中

在 Jetpack Compose 中,使用 时Text,我们可以使用 使文本居中TextAlign

Text(
    text = "How many cars are in the garage",
    textAlign = TextAlign.Center
)
Run Code Online (Sandbox Code Playgroud)

但是,如果我们想要获取文本可组合项中的点击位置,我们可以使用ClickableText

ClickableText(
        text = AnnotatedString("Click Me"),
        onClick = { offset ->
            Log.d("ClickableText", "$offset -th character is clicked.")
        }
    )
Run Code Online (Sandbox Code Playgroud)

但是我不知道如何将 ClickableText 中的文本居中?我可以使用重力,但这只会使组件居中,而不会使其内部的文本居中。

android android-jetpack-compose android-compose-textfield

18
推荐指数
1
解决办法
3535
查看次数