I found an workaround for my problem, it's working, but I don't think is too clean.
So, my scenario was:
- a container table, containing a ScrollPane (another table), under this scrolling table two TextFields and under them a Submit button
- container table set to fill parent (full screen)
- the text fields and the button aligned to the bottom of the container table
The problem was that when the OnscreenKeybord was visible, it covered the bottom objects (text fields and button) and a part of the scrolling table.
My solution / workaround is:
keyboard = new OnscreenKeyboard() {
@Override
public void show(boolean visible) {
Gdx.input.setOnscreenKeyboardVisible(visible);
// Hmmmm...
container.invalidate();
if (visible) {
// TODO get OsK height somehow!!!
container.padBottom(310);
} else {
container.padBottom(0);
}
}
};
textFld1.setOnscreenKeyboard(keyboard);
textFld2.setOnscreenKeyboard(keyboard);
and on the InputListener of the Submit button (on touchDown) I have a cleanup function like:
textFld1.setText("");
textFld2.setText("");
stage.unfocus(textFld1);
stage.unfocus(textFld2);
keyboard.show(false);
In this way the container table will be padded up when the soft keyboard is displayed and it will be restored after the submit button is pressed; also the soft keyboard is hidden.
Now, there are two problems with this workaround:
I have not found a way to get the soft keyboard height; as you can see in the sample code I have chosen an arbitrary value for the up padding, so the tings to look good on my emulator
if hard button Back or ESC in emulator is pressed, the soft keyboard will hide, but the up-padding of the table will still be there; I didn't find how to determine if the soft keyboard is visible or not
If anyone finds another solution for my problem, please post it.
Thanks.