1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Allow to obtain virtual keyboard height

On mobile platforms virtual keyboards take up significant amount of
screen space and UI containing a text box may need to be adjusted
after the keyboard appears to keep the text box visible to user. This
commit adds a way to obtain virtual keyabord height so that controls
are aware of how much they need to move.
This commit is contained in:
Ruslan Mustakov
2017-10-04 15:39:31 +07:00
parent 6dc1025e63
commit 275e537058
14 changed files with 114 additions and 3 deletions

View File

@@ -277,6 +277,21 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
edittext.setView(mView);
io.setEdit(edittext);
final Godot godot = this;
mView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Point fullSize = new Point();
godot.getWindowManager().getDefaultDisplay().getSize(fullSize);
Rect gameSize = new Rect();
godot.mView.getWindowVisibleDisplayFrame(gameSize);
final int keyboardHeight = fullSize.y - gameSize.bottom;
Log.d("GODOT", "setVirtualKeyboardHeight: " + keyboardHeight);
GodotLib.setVirtualKeyboardHeight(keyboardHeight);
}
});
// Ad layout
adLayout = new RelativeLayout(this);
adLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));

View File

@@ -69,4 +69,6 @@ public class GodotLib {
public static native void callobject(int p_ID, String p_method, Object[] p_params);
public static native void calldeferred(int p_ID, String p_method, Object[] p_params);
public static native void setVirtualKeyboardHeight(int p_height);
}