iOS Question ScrollView and a visible Keyboard

TheRealMatze

Active Member
Licensed User
Hello again!
I see one more problem, but this time in the ui itself. Under b4a pages are scrolling up when the keyboard is visible, under b4i it looks like i have to do it by myself.
I have created a new layout only containing a ScrollView and changed the "loadLayout" this way
B4X:
    'Root.LoadLayout("editFarm")
    Root.LoadLayout("scroller") '< only contains a scrollView named "scroller"
    scroller.Panel.LoadLayout("editFarm") '< contains a panel named "scrollPanel" and inside a bounch of textboxes
    scroller.ContentWidth =100%x
    scroller.ContentHeight=scrollPanel.height
The content - text-fields and a combo-box - fits to the page, so there is nothing to scroll as long as the keyboard is hidden.
But when the Keyboard is visible nothing changes...
So the keyboard covers the textfield. That means - i havn´t understand the scrollview correct...

When i add a fictive value to the height (scroller.ContentHeight=scrollPanel.height + 300) the page is scrollable, but not only when the keyboard is visible. Instead of any fixed value i need a trigger that the keyboard is shown and the height of it, correct? And also a method to bring the textview into view i think...

Can anybody tell me what is missing?

Regards
Matthias
 

TheRealMatze

Active Member
Licensed User
Thanks Erel,
i´ve tried to adopt the first option.

editFarmScroll has the header and the ScrollView "scroller", editFarmElements the input-fields (located in panel1).

B4X:
Private Sub B4XPage_Appear

    Root.LoadLayout("editFarmScroll")
    scroller.Panel.LoadLayout("editFarmElements")
        scroller.Height=Root.height-scroller.top
    #if b4a
        scroller.Panel.Height=(Panel1.Height) - (scroller.Height/2) 
    #end if
    #if b4i
        scroller.ContentWidth =100%x
        scroller.ContentHeight=Panel1.Height + 50dip
    #end if
    
End Sub
B4X:
#if b4a
Private Sub IME_HeightChanged (NewHeight As Int, OldHeight As Int)
    Dim KeyboardHeight As Int = Root.Height - NewHeight
    scroller.Height=Root.height - scroller.top - KeyboardHeight
End Sub
#end if
B4X:
#if b4i
Private Sub B4XPage_KeyboardStateChanged (Height As Float)
    If Height>0 Then Height=Height + 20
    scroller.Height=Root.height - scroller.top - Height
End Sub
#end if

Both android and ios-version looking good now. Did I miss anything important?

Regards
Matthias

outside.JPG
 
Upvote 0
Top