Adjust scrollview when keyboard is up

和自甴很熟 提交于 2019-12-09 02:30:48

问题


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?


回答1:


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

 android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan"



回答2:


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




回答3:


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);




回答4:


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.




回答5:


Add below line of code in manifest under Activity tag

android:windowSoftInputMode="adjustResize"



回答6:


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/



来源:https://stackoverflow.com/questions/12422566/adjust-scrollview-when-keyboard-is-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!