Android Question Example of xCLV with auto sizing of added panels

mscientist33

Active Member
Licensed User
Does anyone know of examples of an xCLV with auto sizing of added panels.

I have panels with two labels that get filled with text and then both labels get added to the xCLV. The problem is each time the text might be of different lengths but the panel size stays the same and I have either a big gap between items in the xCLV or text that is cut off.

I am currently using the example from https://www.b4x.com/android/forum/threads/b4x-b4xpages-sql-xclv-example.131888/#content but it has a set height per panel.
 

Sagenut

Expert
Licensed User
Longtime User
Try in this way
B4X:
Private Sub CreateItem(rd As RecordData) As B4XView
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Root.Width, 60dip)
    p.LoadLayout("Item")
    'labels will point to the last loaded views with the set name.
    lblAlbum.Text = rd.AlbumName
    lblArtist.Text = rd.ArtistName
    p.SetLayoutAnimated(0, 0, 0, Root.Width, lblAlbum.Height + lblArtist.Height)
    Return p
End Sub
 
Upvote 0

mscientist33

Active Member
Licensed User
Try in this way
B4X:
Private Sub CreateItem(rd As RecordData) As B4XView
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Root.Width, 60dip)
    p.LoadLayout("Item")
    'labels will point to the last loaded views with the set name.
    lblAlbum.Text = rd.AlbumName
    lblArtist.Text = rd.ArtistName
    p.SetLayoutAnimated(0, 0, 0, Root.Width, lblAlbum.Height + lblArtist.Height)
    Return p
End Sub
It does change the height but it changes them all the same. It's not taking into account the text that is in the labels so each panel is still the same size.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Currently I am not at home in front of pc.
I can try to help you later if no one else do it earlier.
Sorry.
 
Upvote 0

mscientist33

Active Member
Licensed User
Upvote 0
Top