' This method (and the IsFirstResponder() method, below) to ensure the keyboard doesn't cover the relevant
' textfield is taken from here: https://www.b4x.com/android/forum/threads/problem-hide-keyboard.47294/
Private Sub mPage_KeyboardStateChanged(oskHeight As Float)
If oskHeight = 0 Then ' Keyboard has been hidden
mPage.RootPanel.Top = 0
Else ' Keyboard has been shown
For Each pageView As View In mPage.RootPanel.GetAllViewsRecursive
If IsFirstResponder(pageView) Then
Dim viewBottom As Int = pageView.Top + pageView.Height ' This appears to be the problem pageView.Top = 0
Dim keyboardTop As Int = mPage.RootPanel.Height - oskHeight
Dim actualViewBottom As Int = viewBottom + mPage.RootPanel.Top
Dim panelTopModifier As Int = mPage.RootPanel.Top - (oskHeight - (mPage.RootPanel.Height - viewBottom))
If keyboardTop < actualViewBottom Then
mPage.RootPanel.Top = Min(0, panelTopModifier)
End If
Exit
End If
Next
End If
End Sub
' This method (and the mPage_KeyboardStateChanged() method, above) to ensure the keyboard doesn't cover the relevant
' textfield is taken from here: https://www.b4x.com/android/forum/threads/problem-hide-keyboard.47294/.
Private Sub IsFirstResponder(ntvObj As NativeObject) As Boolean
Return ntvObj.RunMethod("isFirstResponder", Null).AsBoolean
End Sub