diff options
author | Ruslan Mustakov <r.mustakov@gmail.com> | 2017-10-04 15:39:31 +0700 |
---|---|---|
committer | Ruslan Mustakov <r.mustakov@gmail.com> | 2017-10-04 17:21:05 +0700 |
commit | 275e537058ed870c4d37002f2110b7866d2ed1ae (patch) | |
tree | 150656cd97e9bae45098829d34d3fd34f1beadb0 /platform/android/java/src/org/godotengine/godot/Godot.java | |
parent | 6dc1025e6313d711939269e1578fff5ffc0cd30a (diff) | |
download | redot-engine-275e537058ed870c4d37002f2110b7866d2ed1ae.tar.gz |
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.
Diffstat (limited to 'platform/android/java/src/org/godotengine/godot/Godot.java')
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/Godot.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 53a90e4cfe..053dfa631a 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -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)); |