Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("Layout")
' --- Your code here ---
' =========================================================
' BYPASS FULLSCREEN
' =========================================================
Dim jo As JavaObject = Me
Dim NativeRootView As JavaObject = Root
jo.RunMethod("ListenToKeyboard", Array(NativeRootView))
End Sub
Private Sub keyboard_heightchanged (NewHeight As Int, OldHeight As Int)
' Your logic here for the Layout.
End Sub
#If Java
import android.graphics.Rect;
import android.view.View;
import android.view.ViewTreeObserver;
import anywheresoftware.b4a.BA;
public void ListenToKeyboard(final View rootView) {
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
int previousHeight = -1;
@Override
public void onGlobalLayout() {
Rect r = new Rect();
// Get the visible screen window
rootView.getWindowVisibleDisplayFrame(r);
// r.bottom is the lowest visible poit
// If the keyboard opens this values decreases
int visibleHeight = r.bottom;
if (previousHeight != visibleHeight) {
if (previousHeight != -1) {
// Trigger B4A event
ba.raiseEventFromUI(null, "keyboard_heightchanged", visibleHeight, previousHeight);
}
previousHeight = visibleHeight;
}
}
});
}
#End If