Activity isn't resizing when keyboard is shown

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 21:31:48

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/43042489/activity-isnt-resizing-when-keyboard-is-shown

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