textfield失去了懒惰的焦点
我正在尝试构建一个UI,该UI在懒惰的布局中包含一个搜索栏。唯一的问题是,如果Textfield不在屏幕顶部,则它将失去焦点。
代码:
val listState = rememberLazyListState()
LazyColumn(
modifier = Modifier.padding(horizontal = 16.dp),
state = listState,
) {
items(7) { // it works with 5 items, but with 7 it doesn't
QuickStart()
}
var text by remember { mutableStateOf(value = "") }
TextField(
value = TextFieldValue(text = text),
onValueChange = { text = it.text }
)
}
我共享了GIF可视化问题。
说明: TextField视图获得焦点,然后失去它,因此系统关闭了键盘。
说明:当TextField上方没有很多元素时,视图如预期的那样工作。在上面添加7个元素之后,它停止工作。
是否有任何解决方案,以便我可以在列表中的其他地方添加EditText?
I'm trying to build an UI that contains a search bar inside a LazyColumn layout. The only problem is that the TextField loses focus if it is not at the top of the screen.
Code:
val listState = rememberLazyListState()
LazyColumn(
modifier = Modifier.padding(horizontal = 16.dp),
state = listState,
) {
items(7) { // it works with 5 items, but with 7 it doesn't
QuickStart()
}
var text by remember { mutableStateOf(value = "") }
TextField(
value = TextFieldValue(text = text),
onValueChange = { text = it.text }
)
}
I've shared gifs visualizing the issue.
Explanation: The TextField view gets focus and then loses it, therefore the system closes the keyboard.
Explanation: The view works as expected when there are not many elements above the TextField. It stops working after adding 7 elements above it.
Is there any solution, so that i can add the edittext somewhere further in the list?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论