Search code examples
androidandroid-layoutwindow-soft-input-mode

Keep viewgroup visible when soft keyboard pops up


Typically, when dealing with soft keyboards, we can specify the layout to resize or pan up when the text field will be hidden.

I have the following layout:

enter image description here

Due to the way it is created (large margin on the bottom from the card), resizing will not work well as it will leave a big gap between the keyboard and the card.

Panning however will keep the password textfield hidden if the username textfield is focused.

Is there a way to specify how far the views should pan, such that it pans up until the FAB?

The only other solution I can think of is to change my padding based on width measure changes, but that sounds like a slightly hacky solution


Solution

  • Your only choices with the softkeyboard are to pan, resize or do nothing. There are no options to effect things like how far it pans.

    The password field may or may not be hidden if the username field is focused. It depends on the size of the screen, height of the keyboard, and your exact layout on that device. But your best solution is probably to make the action key for the username to be ACTION_NEXT and define action next to focus the password field.

    Another good solution would be to get rid of a lot of the negative space above the card- unless there's something there you aren't showing us, its wasted space and placing the card higher on the screen will solve all your problems.