我在列中有一个带有verticalScroll()
的TextField
。
当添加大量字符时,文本字段大小超过键盘范围,我无法看到自己正在输入什么。
我尝试使用这个库,但并没有帮助。
我在列中有一个带有verticalScroll()
的TextField
。
当添加大量字符时,文本字段大小超过键盘范围,我无法看到自己正在输入什么。
我尝试使用这个库,但并没有帮助。
我认为你可以在TextField
中使用BringIntoViewRequester
。
var state by rememberSaveable {
mutableStateOf("")
}
val coroutineScope = rememberCoroutineScope()
val bringIntoViewRequester = remember {
BringIntoViewRequester()
}
TextField(
value = state,
onValueChange = { text ->
state = text
// This will cause the TextField be repositioned on the screen
// while you're typing
coroutineScope.launch {
bringIntoViewRequester.bringIntoView()
}
},
modifier = Modifier
.bringIntoViewRequester(bringIntoViewRequester)
.onFocusChanged {
if (it.isFocused) {
coroutineScope.launch {
delay(400) // delay to way the keyboard shows up
bringIntoViewRequester.bringIntoView()
}
}
},
)
点击此处查看完整示例代码。
您可以在文本的XML中添加android:ellipsize="end"
和android:maxLines="1"
或者您需要的行数,希望对您有所帮助。