我有一个类似于以下代码的NavHost:
NavHost(
navController = navController,
startDestination = Screen.MAIN.route,
modifier = modifier
) {
dialog(
Screen.LOGIN.route,
dialogProperties = DialogProperties(
usePlatformDefaultWidth = false,
dismissOnBackPress = false,
dismissOnClickOutside = false
)
) { LoginScreen() }
composable(Screen.MAIN.route) { MainScreen() }
}
对于可组合的屏幕,我可以配置MainActivity的windowSoftInputMode来调整大小,以及其他参数,例如:
WindowCompat.setDecorFitsSystemWindows(window, false)
但我似乎找不到一种配置我对话框显示方式的方法。它似乎使用了adjustPan功能,因为我可以看到当键盘出现时它会将状态栏向上推。我如何配置这个对话框,或者至少如何更改所提到的对话框的windowSoftInputMode?
编辑 我尝试从上下文访问窗口并明确设置所需参数,但似乎没有任何效果。
val context = LocalContext.current
SideEffect {
val window = context.findWindow()!!
WindowCompat.setDecorFitsSystemWindows(window, false)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
}