B4J Question create label from code but wrap text and set size did not work

stephaniegl

New Member
I do create a label from code, and put it in a pane like this code below
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?
 

zed

Active Member
Licensed User
Did you see that. It's a B4X library. It should work in B4J. (Post#4)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…