stephaniegl
New Member
I do create a label from code, and put it in a pane like this code below
If the label text width more than pane's width the label did not wrap the text and the label witdh did not set like the code.
For example if I input the text "Hello, this is the text to test if the label wrap text can wrap the text to multiline if the text is as long as this" the result in app like the attach pic.
Is anything wrong with my code or is there any solution for me?
B4X:
Public Sub make_Label(number As String, display As String) As Label
Try
Dim txtDesc As Label
txtDesc.Initialize("txtDesc")
Dim width As Double = Pane1.Width * 0.05
Dim height As Double
height = MeasureMultilineTextHeight(fx.DefaultFont(14),width,display)
txtDesc.Font = fx.DefaultFont(14)
txtDesc.Text=display
txtDesc.WrapText=True
txtDesc.Style =".label-enabled {-fx-text-fill: black;} .label-disabled {-fx-text-fill: black;}"
Pane1.AddNode(txtDesc, 15dip, bblTop , width ,-1)
bblTop = bblTop + height + 10dip
Catch
Log(LastException)
End Try
End Sub
If the label text width more than pane's width the label did not wrap the text and the label witdh did not set like the code.
For example if I input the text "Hello, this is the text to test if the label wrap text can wrap the text to multiline if the text is as long as this" the result in app like the attach pic.
Is anything wrong with my code or is there any solution for me?