如何更改UnlinedTextfield中的标签方向

发布于 2025-02-12 08:32:04 字数 276 浏览 1 评论 0 原文

我在JetPack撰写中有一个 OutlinedTextfield ,我想在波斯语的 OutlinedTextfield 的右侧更改标签方向(默认情况下是左侧)。

I have an OutlinedTextField in jetpack compose and I want to change the label direction to the right of OutlinedTextField for the Persian language (By default is on the left).

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往事随风而去 2025-02-19 08:32:04

使用 COMPOINTLOCALPROVIDER(LocallayOutDirection提供LayoutDirection.RTL)

示例代码,

@Composable
fun RtlLabelInOutlineTextField() {
    val (digit1, setDigit1) = remember {
        mutableStateOf("")
    }
    CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
        OutlinedTextField(
            value = digit1,
            onValueChange = {
                setDigit1(it)
            },
            label = {
                Text("Label")
            },
            keyboardOptions = KeyboardOptions(
                keyboardType = KeyboardType.NumberPassword,
                imeAction = ImeAction.Next,
            ),
            modifier = Modifier.fillMaxWidth().padding(16.dp),
        )
    }
}

屏幕截图

”屏幕快照

Use CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl).

Sample code,

@Composable
fun RtlLabelInOutlineTextField() {
    val (digit1, setDigit1) = remember {
        mutableStateOf("")
    }
    CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
        OutlinedTextField(
            value = digit1,
            onValueChange = {
                setDigit1(it)
            },
            label = {
                Text("Label")
            },
            keyboardOptions = KeyboardOptions(
                keyboardType = KeyboardType.NumberPassword,
                imeAction = ImeAction.Next,
            ),
            modifier = Modifier.fillMaxWidth().padding(16.dp),
        )
    }
}

Screenshots

Screenshots
Screenshots
Screenshots

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文