【发布时间】:2021-09-27 02:55:30
【问题描述】:
我正在使用 jetpack compose (1.0.0-beta09) 在我的项目中实现一个屏幕,但我在屏幕上遇到了一个问题,其页脚需要始终可见,即使打开了键盘,我知道我们在 android 上有 'adjustResize' 可以在正常活动中解决这个问题(我有很多带有这种页脚类型的屏幕并且它正在工作),但是如果我将 adjustResize 放在清单或活动的 onCreate 方法上,则在撰写键盘继续隐藏页脚:
这是我没有打开键盘的屏幕,只是为了弄清楚我在说什么
这是打开键盘的屏幕
清单活动标签,我正在尝试在键盘已经打开并且页脚在他上方可见的情况下打开屏幕:
<activity
android:name=".presentation.creation.billing.NewBookingBillingActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/AppThemeBase.Compose"
android:windowSoftInputMode="stateVisible|adjustResize"/>
onCreate 方法:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
injectFeature()
initView()
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
setContent {
BuildScreen()
}
}
我知道在 manifest 和 onCreate 上使用 setSoftInputMode 是多余的,但我正在尝试任何方法。
-
我的屏幕构成范围:
Column(fillMaxSize){
- AppBar
- Box(fillMaxSize){
//lazycolumn used to enable scroll with bottom padding to prevent last item to be hided below the footer
- LazyColumn(fillMaxSize | contentPadding) {
//TextFields of the screen
}
//footer
- Box(fillMaxWidth | height 53 | align.centerBottom){
//footer content
}
}
}
【问题讨论】:
-
您是否查看过处理此问题的 Insets 库? google.github.io/accompanist/insets
-
您找到解决方案了吗?
标签: android android-manifest android-jetpack-compose window-soft-input-mode adjustpan