15

I have an activity with a form in it. Because the form is quite long, I've used a scrollview.

The problem is that the scrollview doesn't change when the keyboard is up. The keyboard overlaps the last part of the scrollview.

How can I make sure that the keyboard is below the scrollview and the scrollview is adjusted to fit the space above it?

In the meanwhile, is there a way to make sure the buttons ‘previous’ and ‘next’ are in the keyboard as well?

Goo
  • 1,318
  • 1
  • 13
  • 31
dumazy
  • 13,857
  • 12
  • 66
  • 113

6 Answers6

13

In the application's manifest file, add the following to the desired <activity /> --

 android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan"
ejavice
  • 48
  • 4
Prashant Mishra
  • 627
  • 5
  • 18
  • 13
    According to Android documentation using multiple 'state*' or 'adjust*' values has undefined results. You should use 'one state', 'one adjust' or 'one state and one adjust' values. – Octavian Aug 16 '13 at 10:18
10

You need to add android:windowSoftInputMode="adjustResize" in the AndroidManifest.xml file.

Bucks
  • 689
  • 3
  • 11
  • 28
4

if you use fragment, you just need to use the code to control it, like below

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

smallfatter
  • 171
  • 1
  • 1
  • 7
3

For ScrollView, I like to use the following soft input mode for the Activity in the AndroidManifest.xml file:

android:windowSoftInputMode="adjustPan"

This works the best for me out of the other options.

Ray Hunter
  • 15,137
  • 5
  • 53
  • 51
1

Note, if you are using CoordinatorLayout, make sure you set android:fitsSystemWindows="false" to be able to make it work for "adjustResize"

The above answers are not enough!

See this article

https://code.luasoftware.com/tutorials/android/move-layout-when-keyboard-shown/

CodingTT
  • 1,125
  • 3
  • 14
  • 23
0
  1. <ScrollView ... android:layout_height="fill_parent" android:fillViewport="true" android:fitsSystemWindows="true" />
  2. Manifest <activity ... android:windowSoftInputMode="stateHidden|adjustResize" /> it's work for me