Android Question Auto size labels inside CustomListView

trueboss323

Active Member
Licensed User
Longtime User
Hello I have took a look at this libary https://www.b4x.com/android/forum/threads/custom-view-autotextsizelabel.30642/
I would like to know how can I have the autosize labels to work inside Custom List View?
I have something like this:

B4X:
    clv.Add(CreateListItem("Title", "Subtitle", clv.AsView.Width, 50dip, Null),50dip, "")

Sub CreateListItem(Text As String, Text2 As String, Width As Int, Height As Int, Image As Bitmap) As Panel

    Dim p as Panel
    p.Initialize("")
    p.Color = Colors.Black
    Dim img1 As ImageView
    img1.Initialize("img1")
    img1.Gravity = Gravity.FILL
    img1.Bitmap = Image
 
    chk.Initialize("chk")
    Starter.mycheckboxes.Add(chk)
 
 
    title.Initialize("")
    title.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
    title.Text = Text
    title.TextSize = 16
    title.TextColor = Colors.White
    Dim subtitle As Label
    subtitle.Initialize("")
    subtitle.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.BOTTOM)
    subtitle.Text = Text2
    subtitle.TextSize = 14
    subtitle.TextColor = Colors.White
    p.AddView(img1, 2dip, 2dip, 50dip, Height - 4dip) 'view #0

    p.AddView(title, 65dip, -7dip, 300dip, Height - 4dip) 'view #1
    p.AddView(subtitle, 66dip, -2dip, 300dip,Height - 4dip) 'view #1
    p.AddView(chk, 88%x, 2dip, 50dip, Height - 4dip) 'view #2
 

    Return p

End Sub

Where "title" and "subtitle" is where i would like to put the Autosize label
 
Last edited:
Top