4

I have a simple activity that displays a big multiline EditText and some other controls below it. I want the activity to resize so the buttons are not hidden by the keyboard when the user is typing in the EditText.

I have tried all sorts of sketchy and non-sketchy solutions I have found online - nothing works.

Here's what I've tried so far:

  • Putting android:windowSoftInputMode="adjustResize" in the manifest.
  • Putting android:fitsSystemWindows="true" in the layout root.
  • Using RelativeLayout vs. LinearLayout as root.
  • Removed all themes from the activity
  • Created a custom theme and put <item name="android:windowFullscreen">false</item> in it.
  • Tried the proposed solution here, with my entire activity layout inside a ScrollView.

Anything left to try?

Community
  • 1
  • 1
Magnus
  • 17,157
  • 19
  • 104
  • 189

2 Answers2

6

Put the following lines in your onCreate()

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

Then your Activity will automatically push up/down when , Key Board shown/hide in screen.

Setting up with , Manifest file , didn't work for me.

Don Chakkappan
  • 7,397
  • 5
  • 44
  • 59
  • 1
    +1000 Thanks! Can't believe something this simple (and that actually works!) hasn't been mentioned in any of the other threads I've looked at regarding this question... They all come up with extremely convoluted and sketchy solutions - ScrollView's , entire classes that only "solve" this problem (without solving it), etc, etc. – Magnus Mar 27 '17 at 09:55
  • @BadCash glad to hear from you.:) – Don Chakkappan Mar 27 '17 at 09:57
  • +1000 thanks!!! For some reasons setting this parameter in the XML doesn't leads the to the same result. THANKYOU. – Caterpillaraoz Oct 09 '19 at 14:57
-1

Put your form inside ScrollView. So that when keyboard pop-out, your components are able to scroll.

Zarul Izham
  • 569
  • 5
  • 17