iOS Question How padding to label?

webhost.company

Active Member
Licensed User
Longtime User
I have a labels in clv with different size
I attached shot from my app
How do I can add space to left and right label?
I tried to add label into panel with special gap but result is not well
 

Attachments

  • photo_2021-09-15_21-26-47.jpg
    photo_2021-09-15_21-26-47.jpg
    49.6 KB · Views: 93

webhost.company

Active Member
Licensed User
Longtime User
I could solve that
My code is :
B4X:
Private Sub AddPadding(lb As Label) As Panel
    
    Dim left,top,width,height As Int
    left = lb.Left
    top = lb.Top
    width = lb.Width
    height = lb.Height
    
    Dim newlbl As Label = lb
    Dim parent As Panel = lb.Parent
    
    lb.RemoveViewFromParent
    
    Dim p As Panel
    p.Initialize("")
    p.Color = Colors.Transparent
    parent.AddView(p,left - 8dip,top,width+8dip,height + 8dip)
    p.AddView(newlbl,8dip,top,width-8dip,height)
    
    Return p
    
End Sub

I remove label and add panel with label position (additional 8dip for left,top,width and height)
and then add main label into panel
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
You can probably use the code from here as a basis for what you are trying to do.

 
Upvote 0
Top