Align text left in libgdx TextButton

Is there a way to align text in a text box on the left (or right) instead of the center? I was looking for him, but I can not find him. This is what you can do with the skin.json file, and if so, how?

Thank you, if I were inaccurate, please let me know :)

+6
source share
2 answers

Yes, you can align the text on the left side of the button, see example:

someButton.getLabel().setAlignment(Align.left); 

so basically you need to align the button label on the left side inside the button. Obviously, you can do the same for correct, top, bottom alignment, etc.

+9
source

It also does the same by โ€œadjusting the position of the cueโ€.

  Skin theSkin= new Skin(); //Create a button style TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle(); textButtonStyle.pressedOffsetY=-4.0f; textButtonStyle.unpressedOffsetY=-4.0f; theSkin.add("default", textButtonStyle); TextButton theButton = new TextButton("New",theSkin); 
0
source

Source: https://habr.com/ru/post/970410/


All Articles