You've already forked godot
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:
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user