0

So I have a main activity with 3 TextFields that are offset from the top because I am using tabbed navigation :

But what happens on small screens is that the keyboard hides the third textfield "Receiver".

How can I solve this ? Would using a ScrollableLayout be a solution (so the user could scroll to unhide the third textfield) ?

ScarySneer
  • 199
  • 3
  • 9

4 Answers4

2

You can achieve this using Accompanist Insets library in three steps :-

1- in your activity call setDecorFitsSystemWindows

WindowCompat.setDecorFitsSystemWindows(window, false)

2- call the ProvideWindowInsets function and wrap your content

ProvideWindowInsets {
  // your content
}

3- call navigationBarsWithImePadding modifier in your content

Full Example :-

WindowCompat.setDecorFitsSystemWindows(window, false)  // step 1
setContent {
    MaterialTheme {
        ProvideWindowInsets { // step 2
            Column(
                modifier = Modifier
                    .navigationBarsWithImePadding() // step 3
            ) {
                // your content
            }
        }
    }
}
0
<application ... >
    <activity
        android:windowSoftInputMode="adjustResize|adjustPan" ... >
        ...
    </activity>
    ...
</application>

Add this to your manifest

https://developer.android.com/training/keyboard-input/visibility[Documentation][1]

android:windowsSoftInputMode defines the positioning of the elements.

0

Paste this in the onCreate before setContent

window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)

Credits:- https://stackoverflow.com/a/64053897/15880865

.

Richard Onslow Roper
  • 5,477
  • 2
  • 11
  • 42
0

So I managed do this using the accompanist library and setting the modifier to Modifier.navigationBarsWithImePadding()

ScarySneer
  • 199
  • 3
  • 9