B4A Class [B4X] [XUI] AutoTextSizeLabel

It is not recommented to use this class in B4J, the textsize is resetting without reasons...

this class is based on the Original Class from @Erel.
It works on B4A, B4I and B4J.
I tested it with B4A and B4I.

IMG_0064 (2).jpg
Screenshot_20181207-150129__01 (1).jpg


Notes:
-XUI is needed

Change log:
- V1.0
  • Release
- V1.1
  • Add RefreshView
  • Add BaseLabel to get the base view, to change view properties
- V1.2
  • BugFix TextSize in B4A on single line was buggy
  • Add Click Event (B4A and B4I only)
  • Add LongClick Event (B4A and B4I only)
- V1.3
  • Removes the Log messages
  • Max Font size is now 200 (before at 80)
  • setRefreshView is now RefreshView
Have Fun
Alex
 

Attachments

  • AutoTextSizeLabel.bas
    6.4 KB · Views: 629
  • ASAutoTextSizeLabel.b4xlib
    2.3 KB · Views: 492
Last edited:

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Alexander

Did you try testing it with with a short Label, say half the height of the left label containing "Two Words", with Text = "ONE".
I tried that and the "ONE" seems to be cutoff

Thanks
iCAB
 

rraswisak

Active Member
Licensed User
It is not recommented to use this class in B4J, the textsize is resetting without reasons...

Hi @Alexander Stolte

The label text size is working for me in B4J, the change i made is:

B4X:
Public Sub setText(value As Object)
   Sleep(0)
   mlbl.Text = value
   Dim multipleLines As Boolean = mlbl.Text.Contains(CRLF)
   Dim size, newSize As Float
   For size = 2 To 80
       newSize = size
       If CheckSize(size, multipleLines) Then Exit
   Next
   'mlbl.TextSize = newSize '<--- replace with line below
   CSSUtils.SetStyleProperty(mlbl,"-fx-font-size",newSize-2)
   Log(size)
   Log(mlbl.TextSize)
End Sub
 
Last edited:
Top