Android Question Unicode Text Word Wrap Problem in Label?

DineshDalwani

New Member
Licensed User
Longtime User
I am trying to load Unicode text from a text file in a label but it wouldn't auto word wrap. Could someone please let me know how to correct this?

Screenshot of the problem and text file in the question are attached.

Here's my Activity code:
B4X:
Sub Globals
    Dim scvText As ScrollView
    Dim lblText As Label
    Dim txt As String
    Dim StrUtil As StringUtils
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Activity.LoadLayout("Layout1")
    scvText.Initialize(100)
    scvText.Color = Colors.RGB(250, 250, 210)
    Activity.AddView(scvText, 0, 0, 100%x, 100%y)
      
    lblText.Initialize("")
    scvText.Panel.AddView(lblText, 0, 0 , 100%x, 100%y)              

    Dim bmp As Bitmap
    bmp.Initialize(File.DirAssets, "ic_action_share.png")
    Activity.AddMenuItem3("Share", "ShareMenu", bmp, True)
  
    bmp.Initialize(File.DirAssets, "ic_action_copy.png")
    Activity.AddMenuItem3("Copy", "CopyMenu", bmp, True)
  
    LoadText
    SetText
End Sub

Sub LoadText
    txt = File.GetText(File.DirAssets, "text1.txt")
End Sub

Sub SetText
    Dim ht As Float
  
    lblText.Text = txt
    ht = StrUtil.MeasureMultilineTextHeight(lblText, txt)
  
    scvText.Panel.Height = ht
    lblText.Height = ht
  
    scvText.ScrollPosition = 0
    DoEvents
End Sub
 

Attachments

  • Screenshot.png
    Screenshot.png
    59.2 KB · Views: 277
  • text1.txt
    1.6 KB · Views: 213
Top