I would like to adjust/re-size the layout when the soft-keyboard activated, as below:
Before and After:
Found couple resources in SO:
- How to keep all fields and texts visible while the soft keyboard is shown
- android soft keyboard spoils layout when appears
- Adjust layout when soft keyboard is on
But the questions & answers are rather ambiguous, here's the question with clearer picture of what I want.
Requirements:
- It should work on phone with any screen sizes.
- Noticed that the margin/padding space at "FACEBOOK" and "Sign Up for Facebook" has changed before and after.
- No scroll view is involved.
Just add
in your AndroidManifest.xml where you declare this particular activity and this will adjust the layout resize option.
some source code below for layout design
Android Developer has the right answer, but the provided source code is pretty verbose and doesn't actually implement the pattern described in the diagram.
Here is a better template:
Its up to you to decide what views you use for the "scrolling" and "footer" parts. Also know that you probably have to set the
ScrollView
s fillViewPort .For me it worked with this line of code:
Just put it into onCreate method. Best!
In my case it helped.
main_layout.xml
Use this in
manifest
fileNow the most important part! Use theme like this in either
Activity
orApplication
tag.And the theme tooks like this
So I was missing the theme. Which made me frustrated all day.
It can work for all kind of layout.
for example:
and
for example:
You can simply set these options in the AndroidManifest.xml file.
The use of
adjustPan
is not recommended by Google because the user may need to close the keyboard to see all the input fields.More info: Android App Manifest