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 i
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);
In the application's manifest file, add the following to the desired <activity />
--
android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan"
You need to add android:windowSoftInputMode="adjustResize" in the AndroidManifest.xml file.
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/
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.
<ScrollView ... android:layout_height="fill_parent" android:fillViewport="true" android:fitsSystemWindows="true" />
<activity ... android:windowSoftInputMode="stateHidden|adjustResize" />
it's work for me