Abh*_*bhi 4 android android-jetpack-compose android-compose-textfield
到目前为止我的解决方案是使用Transparent
光标的颜色。
我正在寻找更好的方法来隐藏它(如果有的话)。
cursorBrush = SolidColor(Transparent)
Run Code Online (Sandbox Code Playgroud)
TextField 应该获得焦点,键盘应该打开并且用户应该能够键入输入。
问题是TextFieldCursorHandle
输入文本后我仍然可以看到。
Gab*_*tti 10
BasicTextField
您可以使用 隐藏光标cursorBrush = SolidColor(Unspecified)
。TextField
你可以使用该属性colors = TextFieldDefaults.textFieldColors(cursorColor = Color.Unspecified)
和TextFieldCursorHandle
选定的文本使用由LocalTextSelectionColors.current
您提供的颜色您覆盖定义自定义的颜色TextSelectionColors
:
val customTextSelectionColors = TextSelectionColors(
handleColor = Color.Transparent,
backgroundColor = Color.Transparent
)
CompositionLocalProvider(LocalTextSelectionColors provides customTextSelectionColors) {
BasicTextField(
value = text,
onValueChange = {text = it},
cursorBrush = SolidColor(Unspecified)
)
TextField(
value = text,
onValueChange = {text = it},
colors = TextFieldDefaults.textFieldColors(cursorColor = Color.Unspecified)
)
}
Run Code Online (Sandbox Code Playgroud)