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:

 
Upvote 0

stevel05

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


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: 93
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…