Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
506 views
in Technique[技术] by (71.8m points)

android - Activity isn't resizing when keyboard is shown

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...