问题
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
RelativeLayoutvs.LinearLayoutas 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