B4A Class Slightly modified AutoTextSizeLabel

Hi everyone, for necessity i added some fields to the famous AutoTextSizeLabel class.
The fields added are:

Version 1.4
  • Access Tag Property: You can now use the .Tag property to set/access this value also from designer
Version 1.3
  • Min Text Size: Specify the minium size of the text of the label (less than this can't go)
  • Max Text Size: Specify the minium size of the text of the label (more than this can't go)
  • Ignore User Font Scale: Specify if the label should ignore the fact that the user could have widened the interface (n.b. default: True)

maybe that are dumb changes, but to me were useful, so.. here you are.

Bye
 

Attachments

  • AutoTextSizeLabel.bas
    7.3 KB · Views: 7
Last edited:

Mike1970

Well-Known Member
Licensed User
Longtime User
Why when i use long text the font size come small automatically ?
It's the desired effect.

Once you set the Label size (e.g. in the designer) the text inside will be scaled automatically to fit inside, taking in account also the Min Text Size and Max Text Size limits.


(maybe I didn't understand correctly what you meant)
 

Mike1970

Well-Known Member
Licensed User
Longtime User
i used this
B4X:
ASL.BaseLabel.TextSize(Max("50"),Min("10"))

but not working there is error
At the moment I can’t pick you an example. I’ll do it later.

However you are not supposed to use it like this.

you can set the limits using the ASL methods.
that should be MinTextSize and MaxTextSize I think (I do not remember).

is this what you wanted to do?
 

Mike1970

Well-Known Member
Licensed User
Longtime User
yes it is.
Ok well, with the version you have just set them in the Designer

Schermata 2022-11-29 alle 09.04.26.png




However, i updated the class adding the two methods
MinTextSize and MaxTextSize

B4X:
Private lblA As AutoTextSizeLabel
lblA.MaxTextSize = 20
lblA.MinTextSize = 5
lblA.Text = "Hello"

(P.S. If you call those methods AFTER you already set the text, you have to call also RefreshView)

The Updated class (Version 1.4) is attached
 

Attachments

  • AutoTextSizeLabel.bas
    7 KB · Views: 122

Alhootti

Member
I tested it

this is not i want it excatlly.

i want when i insert long text the label should extend horizontally only (increase in width only) to occupies the long text automatically dose not matter it extend out of the form.

but the more important thing is the font size still as before not change totally.
 

Mike1970

Well-Known Member
Licensed User
Longtime User
I tested it

this is not i want it excatlly.

i want when i insert long text the label should extend horizontally only (increase in width only) to occupies the long text automatically dose not matter it extend out of the form.

but the more important thing is the font size still as before not change totally.
Ouh ok, so you want the opposite behaviour...
You want the text size to be FIXED and the label size to be dynamic based on the sentence length?... right?
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Take a look at resizingtextcomponent. That might do what you need.

 
Top