Stop the TextButton file from libgdx by resizing depending on the text.

I use a text button that changes the text from OFF to ON when you click on it. But once that happens, the size is completely different. Is there a way to make the button keep the current size? I tried setScale and setSize buttons, but it seems to do nothing. I use the button in the table if that matters.

+3
source share
1 answer

If you are using a table, you must change the size cell.

For example, imagine your code:

TextButton btn = new TextButton(...);
btn.setSize(100, 100);
table.add(btn);

Instead, you should define this:

TextButton btn = new TextButton(...);
table.add(btn).size(100, 100); // <-- resize cell, not button

See this document for more information .

+5
source

All Articles