iOS Question Label Height Problem.

tzfpg

Active Member
Licensed User
Longtime User
i facing a label height problem,here is my code:
B4X:
Sub CreateListItem(left_right_status As Int,Text1 As String,Text2 As String, value As String)
    Dim p As Panel
    Dim p1 As Panel
    Dim lbl1_left As Label
    Dim lbl2_left As Label
    lbl1_left.Initialize("")
    lbl2_left.Initialize("")
    p.Initialize("")
    p1.Initialize("")
   
    If left_right_status = 1 Then
        p1.SetBorder(0dip, Colors.Red, 5dip)
        lbl1_left.Font = Font.DEFAULT_BOLD
        lbl1_left.TextColor=Colors.Black
        lbl1_left.Font = Font.CreateNew(12)
       
        lbl2_left.TextColor=Colors.White
        lbl2_left.Font = Font.CreateNew(16)
        p.Color=Colors.Transparent
        p1.Color=Colors.ARGB(255,58,155,250)
        lbl2_left.Multiline=True
   
        lbl1_left.Text = Text1
        lbl2_left.Text = Text2
               
        p1.AddView(lbl1_left,2%x,0%y,79%x,4%y)
        p1.AddView(lbl2_left,2%x,4%y,79%x,10%y)
       
        lbl1_left.SizeToFit
        lbl2_left.SizeToFit
       
        p.AddView(p1,2%x,0,80%x,lbl1_left.Height+lbl2_left.Height+5dip)
        clv_msg.Add(p,lbl1_left.Height+lbl2_left.Height+5dip,"")
       
    Else If left_right_status = 0 Then
        p1.SetBorder(0dip, Colors.Red, 5dip)
        lbl1_left.Font = Font.DEFAULT_BOLD
        lbl1_left.TextColor=Colors.Black
        lbl1_left.Font = Font.CreateNew(12)
       
        lbl2_left.TextColor=Colors.White
        lbl2_left.Font = Font.CreateNew(16)
        p.Color=Colors.Transparent
        p1.Color=Colors.ARGB(255,3,156,15)
        lbl2_left.Multiline=True
   
        lbl1_left.Text = Text1
        lbl2_left.Text = Text2
       
        p1.AddView(lbl1_left,2%x,0%y,74%x,4%y)
        p1.AddView(lbl2_left,2%x,4%y,74%x,10%y)
       
        lbl1_left.SizeToFit
        lbl2_left.SizeToFit
       
        p.AddView(p1,20%x,0%y,78%x,lbl1_left.Height+lbl2_left.Height+5dip)
        clv_msg.Add(p,lbl1_left.Height+lbl2_left.Height+5dip,"")
       
    End If
End Sub
first time get in the message page, all show in perfect.
screenshot below:
IMG_0025.PNG

but after that, all going wrong.
screenshot below:
IMG_0026.PNG
how to solve this problem. I'm totally no idea to solve it.
please help me.
Thanks!
 

tzfpg

Active Member
Licensed User
Longtime User
Here is testing project. Please check for me. Thank you.
 

Attachments

  • testing.zip
    27.1 KB · Views: 186
Upvote 0

strat

Active Member
Licensed User
Longtime User
In order to correction %x and %y problems, I use simple converting. Inside Page_Resize event, I detect screen size and assign to public x and y variables. Then I use this x and y variables instead of %x and %y. Your code works for me after %x calculations.
 

Attachments

  • testing.zip
    27.2 KB · Views: 179
Upvote 0
Top