iOS Question Another scrollview height Question

jahswant

Well-Known Member
Licensed User
Longtime User
I don't really understand why this code doesn't work. I've got a long layout but instead of making it scrolable it seems like it instead streches it out.

B4X:
Private Sub ReportsPage_Resize(Width As Int, Height As Int)
    
    ScrollViewMain.Panel.LoadLayout("reports")

    ScrollViewMain.ContentWidth= Width
    '
    ScrollViewMain.ContentHeight= pnlReports2.Height
End Sub

What's the solution for content Height ?
HAya.png
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Loading a layout inside the resize event can be risky. Don't assume that it will be called once.
It is also not needed if you build the layout correctly with the designer.

2. I guess that pnlReports2 is a view from the reports layout. You should make it vertically anchored to both sides and set ScrollViewMain.ContentHeight based on the height you like it to be. It is always the container that sets the sizes of the inner views.
 
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
I tried this Same Issue...

B4X:
Public Sub Show
    
        If ReportsPage.IsInitialized = False Then
            ReportsPage.Initialize("ReportsPage")
            ReportsPage.RootPanel.Color = Colors.White
            ReportsPage.RootPanel.LoadLayout("mainreports")
        End If
        Main.NavControl.NavigationBarVisible = False
        Main.NavControl.ToolBarVisible = False
        Main.NavControl.ShowPage(ReportsPage)
    
        ScrollViewMain.Panel.LoadLayout("reports")
End Sub

B4X:
Private Sub ReportsPage_Resize(Width As Int, Height As Int)
    
    ScrollViewMain.ContentWidth= Width
    '
    ScrollViewMain.ContentHeight= pnlReports2.Height
End Sub
I've attached the layout files.
 

Attachments

  • Files.zip
    9 KB · Views: 168
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
The container should set the height and the child views will adapt (assuming that you are correctly using anchors and designer script).
@Erel I'm tired trying to make this work for 4 days now. I've uploaded a test project to reproduce this issue. It's like the layout stops loading at 100%y. I don't really understand this. My Layout is Correctly written with Designer Scrips.
 

Attachments

  • TestScrollView.zip
    15.5 KB · Views: 164
Upvote 0
Top