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)
)
}
cursorBrush = SolidColor(Color.Transparent)
应用于您的BasicTextField
。 - Gabriele Mariotti