如何更改 OutlinedTextField 中的标签方向

Sae*_*adi 3 android textfield android-jetpack-compose

我有一个jetpack compose,我想将波斯语的OutlinedTextField标签方向更改为右侧(默认情况下位于左侧)。OutlinedTextField

在此输入图像描述

Abh*_*bhi 5

使用CompositionLocalProvider(LocalLayoutDirection provides 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),
        )
    }
}
Run Code Online (Sandbox Code Playgroud)

截图

截图 截图 截图