android-jetpack-compose - Jetpack 撰写 Justified 和 R

在 Jetpack Compose 中,您可以像这样对齐 Text:

Text(
       text = text,
       textAlign = TextAlign.Justify
    )

如果您想要支持 RTL,可以通过以下方式实现:

Text(
       text = text,
       textAlign = TextAlign.Right
    )

Text() 如何支持 RTL 文本并同时在 Jetpack Compose 中证明它的合理性?

最佳答案

经过几个小时的测试,我得到了这个:

@Composable
fun JustifiedRTLText(
    text: String,
    modifier: Modifier = Modifier
) {
    CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
        Text(
            text = text,
            textAlign = TextAlign.Justify,
            modifier = modifier,
        )
    }
}

关于android-jetpack-compose - Jetpack 撰写 Justified 和 RTL 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70288108/

相关文章:

microsoft-graph-api - MS Graph Mail 在商店中找不到指定的对象

rust - 在 ".map(|x| *x)"之前是否有更好的 ".collect()"替代品?

phpunit - 在 php 8.1.0 上使用 phpunit 9.4 捕获警告、通知和弃用

go - 为什么 DefaultMask() 方法在 Golang 中有一个 IP 类型的接收者?

spring - 摆脱 spring-boot-starter-data-mongodb 对易受攻击

amazon-web-services - Docker 推送错误保存凭据 : error stor

javascript - 如何使用顺风向表格添加间距

graphql - 为什么 graphcms graphql 给我一个 403 错误?

php - 为什么php artisan make :factory not Generating

java - 当我们调用 function(2) 时,为什么这个函数返回 83 而不是 5?