[英]Jetpack Compose Button goes above keyboard?
I have some content and a TextField, and a button on the bottom of the screen.我有一些内容和一个TextField,以及屏幕底部的一个按钮。 When I tap on the TextField, the keyboard covers my button, but obviously I want the button to go above the keyboard.
当我点击 TextField 时,键盘盖住了我的按钮,但显然我希望按钮位于键盘上方的 go 上。 How can I do that?
我怎样才能做到这一点?
I already added this line to my MainActivity, before setContent():在 setContent() 之前,我已经将此行添加到我的 MainActivity:
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
My Scaffold:我的脚手架:
Scaffold { padding ->
Box(
modifier = Modifier
.padding(20.dp)
.padding(top = 40.dp)
.fillMaxSize()
) {
Column {
Text("My content")
Text("My content")
Text("My content")
TextField(
value = text,
onValueChange = { text = it },
)
}
Box(
modifier = Modifier.align(Alignment.BottomCenter)
) {
Button(content = { Text("BTN") }, onClick = {})
}
}
}
Add android:windowSoftInputMode="adjustResize"
to the AndroidManifest.xml
.将
android:windowSoftInputMode="adjustResize"
添加到AndroidManifest.xml
。 You're cured!你痊愈了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.