2

我正在使用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"/>

创建方法:

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        injectFeature()
        initView()

        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
        
        setContent {
            BuildScreen()
        }
    }

我知道在清单和 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
     }
     
   }
}

4

1 回答 1

1

我想问题出在你的LazyColumn修饰符上。如果你设置weight为 1f。它会起作用的。

Column(Modifier.fillMaxSize()) {
    TextField(value = "", onValueChange = {})
    TextField(value = "", onValueChange = {})
    LazyColumn(Modifier.weight(1f)) {

    }
    Row {
       Button(onClick = { /*TODO*/ }) {
           Text(text = "Ok")
       }
    }
}

结果如下:

在此处输入图像描述

于 2021-07-20T14:09:34.380 回答