Android Question Scrollable Activity

DawningTruth

Active Member
Licensed User
How do I create the following layout:

R1ecl4.jpg

Essentially I want to have a scrollable long page. Which can have numerous different elements.

Ideally I would like to create this layout in the Visual Designer.

Have tried the scrollview but it does not allow me to embed a panel into it.

Any suggestions...
 

DawningTruth

Active Member
Licensed User
Tried that approach but clearly missing something. I'm just getting a blank activity with just the activity title.

Here is the layout file "LongLayout":

HuSbaV.jpg


And here is the code:

B4X:
Sub Globals
    Private scrollView1 As ScrollView   
    Private pnl_myPage As B4XView   
    Private lbl_myTitle As B4XView
    Private btn_Back As B4XView
    Private lbl_Subheading1 As B4XView
    Private lbl_Subheading2 As B4XView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    scrollView1.Initialize(0)
    scrollView1.Panel.LoadLayout("LongLayout")
    Activity.AddView(scrollView1,0,0,100%x,100%y)

End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Try this one:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    scrollView1.Initialize(0)
    Activity.AddView(scrollView1,0,0,100%x,100%y)
    scrollView1.Panel.LoadLayout("LongLayout")
    scrollView1.Panel.Height = pnl_myPage.Height
End Sub

You could also define a layout with the ScrollView using anchors.

You could have a look at ScrollView example with a Panel higher than the screen.
 
Upvote 0

DawningTruth

Active Member
Licensed User
It is a mistake to load a layout before the parent size is set. It should be:
B4X:
    scrollView1.Initialize(870dip) 'based on the inner layout height
    Activity.AddView(scrollView1,0,0,100%x,100%y)
    scrollView1.Panel.LoadLayout("LongLayout")
Thx Erel, good tip. Working now.
 
Upvote 0
Top