Jolly
Jolly

Reputation: 399

Align text left in libgdx TextButton

is there a way to align the text in a textbutton to left (or right) instead of center? I'v looked for it, but I cant seem to find it. Is it something that you can do with a .json skin file, and if so, how?

Thanks, if I was unprecise please let me know :)

Upvotes: 9

Views: 6474

Answers (2)

VARUN ISAC
VARUN ISAC

Reputation: 443

This also does the same thing, "adjusting the label position".

    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);

Upvotes: 0

donfuxx
donfuxx

Reputation: 11321

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

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

so basically you have to align the button´s label to the left side inside the button. Obviously you can do the same for right, top, bottom alignment etc.

Upvotes: 13

Related Questions