Search code examples
androidkeyboardbackground-imagecodenameone

Codename One Keyboard Cover Image


I have an Android application with a text field. When I start typing, the keyboard pushes the background image upwards.

I want the image to stay in place and the keyboard to cover it, instead.

Changing the layout to BoxLayout or BorderLayout does not have any effect on the position of the background image, neither does changing scrollable:

container.setScrollableY(false);
form.setScrollableY(false);

How would I achieve keeping the image in place?

One other thing I was unable to figure out was accessing the form with the cursor already in the TextField and the keyboard visible, setting:

textField.requestFocus();

But that also does not have the desired effect.

Any help would be appreciated.

enter image description here


Solution

  • Text fields must be in a scrollable parent.

    If the image and the text field are in the same container and the text field is above the image you might get something closer to the second image. On iOS the scroll region is increased to accommodate the virtual keyboard, on Android the screen is resized to accommodate it.

    This can lead to nuanced behavior difference as the size of the screen adapts.