Dim s As String=$"I am porting a code from B4A and I should measure the height of a multiline text.
I cannot use label.SizeToFit because I have to fix the width and determine the height.I am so sorry but I don't understand
your suggestion. I am porting the baloon library for B4A in B4i. It extensively uses MeasureMultilineTextHeight to determi
ne the right height once the width is defined. Moreover I modified this library to allow the user to resize the width of the
ballons. SizeToFit doesn't appear to me able to lock the width.
In CustomListView I find this code:"$
Log("s height:"&s.MeasureHeight(Font.DEFAULT))
Label1.Text=s
Dim txth As Double=Label1.Text.MeasureHeight(Label1.Font)
Log("lbl height:"&txth)
Label1.Height=txth
Label2.Text=s
Label2.SizeToFit
the log:
B4X:
Copying updated assets files (1)
Application_Start
s height:116.9492
lbl height:116.94921875
Application_Active
label2Height:320'this one is log by topright btn click(after sizetofit excute)
the label1 and label2 use the same font and fontsize (onely the colors are not same)
what's wrong with this problem please?
I'm creating a layout which have same dynamic content(with some ui item),but the resize event is before content fill,so I cannot use sizetofit directly?
Dim s As String="I am porting a code from B4A and I should measure the height of a multiline text."&CRLF&"I cannot use label.SizeToFit because I have to fix the width and determine the height.I am so sorry but I don't understand "&CRLF&"your suggestion. I am porting the baloon library for B4A in B4i. It extensively uses MeasureMultilineTextHeight to determi"&CRLF&"ne the right height once the width is defined. Moreover I modified this library to allow the user to resize the width of the "&CRLF&"ballons. SizeToFit doesn't appear to me able to lock the width."&CRLF&""&CRLF&"In CustomListView I find this code:"
'mode 1 width,2 height
Public Sub setLblWrapContent(lbl As Label,mode As Int)
Dim h,w,ow,oh As Double
ow=lbl.Width
oh=lbl.Height
h=MeasureText(lbl,lbl.Text)(1)
w=MeasureText(lbl,lbl.Text)(0)
If mode=1 Then
lbl.Width=h*w/oh
Else
lbl.Height=h*w/ow
End If
lbl.SizeToFit
End Sub
Sub MeasureText(lbl As Label,txt As String) As Double()
lbl.Text=txt
lbl.SizeToFit
Dim Result(2) As Double
Result(0) = lbl.Width
Result(1) = lbl.Height
Return Result
End Sub