简体   繁体   中英

AdjustResize on jetpack compose not working

I'm implementing a screen on my project using jetpack compose (1.0.0-beta09) but I'm facing a issue on a screen with a footer that need to be always visible, even the keyboard is opened, I know that we have 'adjustResize' on android that solve this problem in a normal activity (I've a lot of screens with this footer type and it's working), but on compose if I put adjustResize on manifest or on the onCreate method of the activity the keyboard continue hiding the footer:

That's my screen without the keyboard opened, just to figure what I'm talking about

这是我没有打开键盘的屏幕,只是为了弄清楚我在说什么

And that's the screen with the keyboard opened

这是打开键盘的屏幕

The manifest activity tag, I'm trying to open the screen with the keyboard already opened and the footer visible above him:

 <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 method:

 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) injectFeature() initView() window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) setContent { BuildScreen() } }

I know that's redundant use setSoftInputMode on manifest and on onCreate, but I'm trying anything.

-

My screen compose scope:

 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 } } }

I guess the problem is in your LazyColumn modifier. if you set weight to 1f. It will work.

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

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

Here's the result:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM