iOS Question Get label height

webhost.company

Active Member
Licensed User
Longtime User
Hello
I cannot get correct height of label with using String.MeasureHeight
The result number is very small and label not show complete
I attach picture
 

Attachments

  • Screen Shot 2017-05-03 at 4.21.17 PM.png
    29.5 KB · Views: 218

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is the code used by CustomListView to set the label's height:
B4X:
Public Sub InsertAtTextItem(Index As Int, Text As String, Value As Object)
   Dim pnl As Panel
   pnl.Initialize("")
   Dim lbl As Label
   lbl.Initialize("")
   lbl.TextAlignment = lbl.ALIGNMENT_LEFT
   pnl.AddView(lbl, 5dip, 2dip, sv.Width - 5dip, 20dip)
   lbl.Text = Text
   lbl.Multiline = True
   lbl.Font = DefaultTextFont
   lbl.TextColor = DefaultTextColor
   pnl.Color = DefaultTextBackgroundColor
   lbl.SizeToFit
   lbl.Height = Max(50dip, lbl.Height)
   InsertAt(Index, pnl, lbl.Height + 2dip, Value)
End Sub
 
Upvote 0

webhost.company

Active Member
Licensed User
Longtime User
I know but i add label in designer and use your code but not apply on label
 
Upvote 0

webhost.company

Active Member
Licensed User
Longtime User
I use below code for get height of label and increase scrollview panel height
but not working
B4X:
    lblbody.Text = re
    lblbody.SizeToFit
   
    sv1.Panel.Height = lblbody.Height + sv1.Panel.Height
 
Upvote 0

webhost.company

Active Member
Licensed User
Longtime User
I found solution for apply SizeToFit on label in Page_Resize
But again i have problem
I download data from site and show it in label when i show page
And Page_Resize raise after show page and after show page, my data downloaded and then show so i cannot use page_resize for fit label
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…