B4A Library JustifyTextView Wrapper

JustifyTextView With this library you can justify the text in a textView.
Version:
1
  • JustifyTextView
    Fields:
    • ba As BA
  • Methods:
    • AddToParent (Parent As ViewGroup, left As Int, top As Int, width As Int, height As Int)
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
      Initializes the view.
      Example :
      Dim MyView As JustifyTextView
      MyView.Initialize("MyView")
      Activity.AddView(MyView,0,0,100%x,100%y)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • SetText (st As String, wrap As Boolean)

      st: String to Justify.
      wrap: Set to true or false depending on what you want.
      Example
      Dim From As String
      From = File.ReadString(File.DirInternal, "from.txt")
      MyView.SetText(From,False)
  • Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Tag As Object
    • TextSize As Int [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
1.png
2.png
 

Attachments

  • justifyEx.zip
    8.6 KB · Views: 637
  • justifyLib.zip
    8.1 KB · Views: 672
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Thank @Johan Schoeman for this fantastic new functions.

All work, but if i use with UltimateListView i have this error:



I have this code in ULV ( nothing of special )
B4X:
Sub Item_LayoutDettagli(LayoutName As String, LayoutPanel As Panel)

        Dim lbl1 As Label
        lbl1.Initialize("")
        lbl1.TextColor = Colors.Black
        lbl1.TextSize = FontSize
        lbl1.Typeface = Typeface.DEFAULT_BOLD
        lbl1.Gravity = Gravity.TOP
        LayoutPanel.AddView(lbl1, 0, 0, LayoutPanel.Width, 25dip)


        Dim Giustifica1 As JustifyTextView
        Giustifica1.Initialize("Giustifica1")
         LayoutPanel.AddView(Giustifica1, Padding, 26dip, LayoutPanel.Width - (Padding * 2), LayoutPanel.Height + (Padding * 2))
     
End Sub

Sub Item_ContentDettagli(ItemID As Long, LayoutName As String, LayoutPanel As Panel, Position As Int)

    Dim lbl_titolo As Label = LayoutPanel.GetView(0)
    lbl_titolo.Text = dettagli.Get("log_Titolo" & Position)
    lbl_titolo.Tag = ""

        Dim Giustifica1 As JustifyTextView = LayoutPanel.GetView(1)
        Giustifica1.SetText(dettagli.Get("log_valore" & Position), True) '<----- HERE ERROR
 
End Sub

With "old" library this error i havent..... ( same code ).
Any idea ??
Thank you
Try with the attached lib files. I have kept the package names the same as what they are in the original project by @jahswani
 

Attachments

  • JustifyTextViewLibFiles.zip
    9 KB · Views: 355

Johan Schoeman

Expert
Licensed User
Longtime User

Attachments

  • b4aexample.zip
    10 KB · Views: 306

Johan Schoeman

Expert
Licensed User
Longtime User
tnx ,but this does replace word(this is a word ---->word a is this)
The idea was to get the Gravity added - Attached is the Java code - you can amend it to allow for RTL languages NORMAL/JUSTIFY. There are various options for Gravity
 

Attachments

  • TheJavaCode.zip
    15.3 KB · Views: 319

mshafiee110

Active Member
Licensed User
Longtime User
The idea was to get the Gravity added - Attached is the Java code - you can amend it to allow for RTL languages NORMAL/JUSTIFY. There are various options for Gravity
wow,tnx a lot.:)
You 're very generous
 

Devv

Active Member
Licensed User
Longtime User
HI all
i have the same problem with RTL language (arabic)
it is not working for me the results after justify is always gravity left , doesent matter that gravity i set
in idea ?
 

meysampro

Member
hi,
this lib is awesome
when I use
MyView.SetText(From,True)
unfortunately, text gravity not working for the center horizontally and right
 
Top