Try to save keyboard height for moving screen with it later

This commit is contained in:
Benau
2019-05-19 17:41:51 +08:00
parent ede56a3cf8
commit 766c971339
3 changed files with 36 additions and 3 deletions

View File

@@ -2,19 +2,38 @@ package org.supertuxkart.stk_dbg;
import android.app.NativeActivity;
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.inputmethod.InputMethodManager;
import android.view.KeyEvent;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.View;
public class SuperTuxKartActivity extends NativeActivity
{
private native void saveFromJavaChars(String chars);
private native void saveKeyboardHeight(int height);
@Override
public void onCreate(Bundle instance)
{
super.onCreate(instance);
System.loadLibrary("main");
final View root = getWindow().getDecorView().findViewById(
android.R.id.content);
root.getViewTreeObserver().addOnGlobalLayoutListener(new
OnGlobalLayoutListener()
{
@Override
public void onGlobalLayout()
{
Rect r = new Rect();
root.getWindowVisibleDisplayFrame(r);
int screen_height = root.getRootView().getHeight();
int keyboard_height = screen_height - (r.bottom);
saveKeyboardHeight(keyboard_height);
}
});
}
@Override