Green_qaue
Green_qaue

Reputation: 3661

LibGdx - Use two styles in one TextButton

How can I use two styles in the same TextButton?

 TextButton rankedGame = new TextButton(bundle.get("play"), buttonPlayStyle);

I would like to add a sub-heading to "PLAY" in a smaller font, is it possible?

Upvotes: 1

Views: 56

Answers (1)

Tenfour04
Tenfour04

Reputation: 93779

A Button is a subclass of a Table, so you can add another label to it for your secondary text, like this:

Label subheadingLabel = new Label("test", skin, "mySmallFont");
rankedGame.getLabelCell().row().add(subheadingLabel);

On the second line you can chain on methods for table cells to align it, such as using .expandX().center() to center it, for example. And if your subheading is wider than the main text, you could do the same to the main text to center it:

rankedGame.getLabelCell().expandX().center();

Upvotes: 2

Related Questions