Android Question xCustomListView the Keyboard hides B4XFloatTextField

angel_

Well-Known Member
Licensed User
Longtime User
I use B4XPages where I load a Layout with a xCustomListView, to this xClv I load a panel (as B4XView) with differents views, including B4XFloatTextField when I select those that are lower than the keyboard hides the view, there is some way to avoid it?
 

Mahares

Expert
Licensed User
Longtime User
there is some way to avoid it?
Post #8 in the below thread gets you started with the IME_HeightChanged event :
Then you use the IME_HeightChanged event for the panel holding the child views like the B4XTextField and others in any B4XPage. If you get stuck, come back with your code and layout. Somebody will help.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Here is some code from a project of mine very much as @Mahares describes. I use a scrollview but the principle is the same. The scrollview is fullpage so when the IME keyboard opens I move the bottom of the scrollview up. Each EditText is on a panel, and you need to use the FocusChanged event of the text box to find out which panel is the target. Then you scroll the scrollview so that the target panel is visible.

It is much simpler than it sounds. Here is the code ...

B4X:
Sub Globals

' ...   

    Dim inputPanelPos As Int       ' Bottom of focussed text panel
    Dim workHeight As Int = 0        ' Current keyboard height

' ...
End Sub
    

' Calculate position of base of currently focussed text panel
Private Sub text_FocusChanged (HasFocus As Boolean)
    Dim v As EditText = Sender
    Dim p As Panel = v.Parent
    If HasFocus Then inputPanelPos = p.top + p.Height
    If (workHeight > 0) Then scrBase.ScrollPosition = inputPanelPos - workHeight
End Sub

Private Sub IME_HeightChanged (NewHeight As Int, OldHeight As Int)
    If (NewHeight < OldHeight) Then    ' Keyboard is open
        workHeight = NewHeight
        scrBase.SetLayout(0, 0, Activity.Width, NewHeight)
        scrBase.ScrollPosition = inputPanelPos - NewHeight
    Else
        scrBase.SetLayout(0, 0, Activity.Width, Activity.Height)
        workHeight = 0                  ' Keyboard closed
    End If   
End Sub
 
Upvote 0
Top