[英]Android Jetpack Compose BasicTextField scroll to top when get focus, how to stop it
When BasicTextField has too much content to scroll up and down, scroll to bottom, request focus and show keyborad, it will scroll to top automatically.当 BasicTextField 内容过多,上下滚动、滚动到底部、请求焦点和显示键盘时,它会自动滚动到顶部。 I want it stay in its original postion, how can I do?
我希望它保持在原来的位置,我该怎么办?
You can simply handle it like this and modify the code according to your needs您可以简单地这样处理并根据您的需要修改代码
val scrollState = rememberScrollState()
var verticalScrollEnabled by remember { mutableStateOf(false)}
BasicTextField(
modifier = Modifier
.onFocusChanged {
if (it.isFocused) {
verticalScrollEnabled = true
}
}
.verticalScroll(scrollState, verticalScrollEnabled),
value = "LONG TEXT",
onValueChange = {}
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.