Android Question How to justify label text in b4a ?

systems1

Member
Licensed User
Longtime User
Hello,

How can i give alignment for a label text content like justify/left/right ?

Because i need to justify some text inside a label.

Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
have a look at the Textstyle-Properties in Designer but i dont know how to set them in code
 
Upvote 0

Eric H

Active Member
Licensed User
Longtime User
There are a couple threads already on this, but here is an example:
B4X:
lbl.Gravity = Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL)

If you are using the designer, just expand the text style properties and set the alignment there.
 
Upvote 0

systems1

Member
Licensed User
Longtime User
There are a couple threads already on this, but here is an example:
B4X:
lbl.Gravity = Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL)

If you are using the designer, just expand the text style properties and set the alignment there.

Thanks for your reply.

But this code does't work for me. i have done this already, but i want to justify the text. the code which you given is not justifying text.
 
Upvote 0

Eric H

Active Member
Licensed User
Longtime User
I didn't realize you were wanting to do a full justify. Android does not support this in a textview. Some folks over at stack overflow found a hacked way to do it using HTML/webview instead of a textview.. http://stackoverflow.com/questions/1292575/android-textview-justify-text
The only other solution I can think of would be to change your font size to fill the width, but that would not work for very many use-cases.
 
Upvote 0
Top