B4J Question Center text

GarryP64

Member
B4J noob question:
is there a way to center text in a textarea or textfield? I want a display for temperature that could be 4 or 5 digits long with the decimal point and it would look much better if centered.
 

emexes

Expert
Licensed User
B4J noob question:
is there a way to center text in a textarea or textfield? I want a display for temperature that could be 4 or 5 digits long with the decimal point and it would look much better if centered.

Maybe a label will do the job:

1690434934857.png
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You can do it with a stylesheet.

1690461755694.png

B4X:
.centered-text-area .text {
    -fx-text-alignment: center;
}

and add a StyleClass to the Textarea
B4X:
TextArea1.As(Node).StyleClasses.Add("centered-text-area")

Project with stylesheet is attached if needed.
 

Attachments

  • TextareaCenterText.zip
    2.4 KB · Views: 102
Last edited:
Upvote 0
Top