iOS Question Fit to width on resize for CreateListItem

cbanks

Active Member
Licensed User
Longtime User
How do I get the labels to fit the width of the screen when I rotate the device? I'm adding labels/lines to a customlistview with this code:

B4X:
clv2.Add(CreateListItem(Line, clv2.AsView.Width, 50dip), 50dip, "")

And the CreateListItem code looks like:

B4X:
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
    'Panel
    Dim p As Panel
    p.Initialize("")
    p.Color = Colors.White
   
    'Label
    Dim lbl As Label
    lbl.Initialize("lbl")
    lbl.TextAlignment = lbl.ALIGNMENT_LEFT
    lbl.Text = Text
    lbl.Font = Font.CreateNew(16)
   
    'Add label to panel
    p.AddView(lbl, 5dip, 2dip, 100%x, Height - 4dip) 'view #0
    Return p
End Sub

I'm not sure what else to put in the resize sub because the lines go all the way across the width on rotate, but lines that have lots of text do not resize to take advantage of more width:

B4X:
Private Sub PageHistory_Resize(Width As Int, Height As Int) 'History Page
    clv2.SetSize(100%x, 100%y)
End Sub
 
Top