[英]how to make cursor on BasicTextField be centered on jetpack compose?
I have a problem, where I need a BasicTextField to customize the TextField as I want.我有一个问题,我需要一个 BasicTextField 来根据需要自定义 TextField。
Here I have tried to do a custom, but there is a problem with the cursor in the BasicTextField, it doesn't center align, what I need is center alignment这里我试过自定义,但是BasicTextField中的cursor有问题,没有居中对齐,我需要的是center alignment
Expectation:期待:
i code like this我这样编码
BasicTextField(
value = value,
onValueChange = onValueChange,
decorationBox = { innerTextField ->
Column(
modifier = Modifier
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
innerTextField()
Space(height = 8.dp)
Divider()
}
}
)
You can apply textAlign = TextAlign.Center
to the textStyle
attribute in the BasicTextField
.您可以将textAlign = TextAlign.Center
应用于BasicTextField
中的textStyle
属性。
Something like:就像是:
BasicTextField(
value = text,
onValueChange = { text = it },
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
decorationBox = { innerTextField ->
Column(
modifier = Modifier
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
innerTextField()
Spacer(modifier = Modifier.height(8.dp))
Divider()
}
}
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.