iOS Question Problem with SrollView

ciginfo

Well-Known Member
Licensed User
Longtime User
Hello,
I can not use the scrollview. I can not place views in scrollviews, they do not appear.
Can you tell me what it is wrong in the attached file. The scrollview is built with the Designer and Label is added by code. Alfa level scrollview is on 1 in the designer.
The label never appears. What I'm doing wrong.
Thank you
 

Attachments

  • Scrollview_essai.zip
    2.4 KB · Views: 241

stevel05

Expert
Licensed User
Longtime User
You are using the dimensions of the RootPanel to size the scrollview width before it has been sized, move the call to createscrollview sub into the Page1_Resize sub.

You should really just size it there, so you will need to split the create sub into two, create and size and call the size from the Page1_resize sub, or you will end up with multiple labels on the scrollview.

You'll also need to resize the label.


B4X:
Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("Page1")
    Page1.Title = "Page 1 et Scrollview"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    CreateScrollView

End Sub
Public Sub CreateScrollView
 
        LblTitre.Initialize("LblTitre")
        LblTitre.Color = Colors.Green
        LblTitre.Text = "Mon Titre"
        LblTitre.Font = Font.CreateNew(12)'taille du caractere
        LblTitre.TextAlignment = LblTitre.ALIGNMENT_CENTER
        LblTitre.BringToFront
        sv.Panel.AddView(LblTitre, 0, 0, 100%x, 50dip)

End Sub
Sub SizeScrollView
    sv.ContentWidth = Page1.RootPanel.Width
    sv.ContentHeight = 1000dip
    LblTitre.Width = sv.ContentWidth
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
    SizeScrollView
End Sub
 
Last edited:
Upvote 0
Top