Libgdx TextField set size

I’m trying to set the size of a TextField, but it doesn’t seem to change the size.
I’d also like to know how to increase the font size inside the TextField.

Here is the code I’m using:


TextField textField = new TextField("", skin");
textField.setSize(100, 100);
textField.setPosition(10, 390);
textField.pack();

stage.addActor(textField);

Thanks!

I found out how to do this, you need to set the size after you pack() or add it to the stage (I’m not sure which, I’ve done both).

Hi hugotheman,

I know you got it to work, but to answer your question the UI components do not set their own sizes, the parent (in your case stage) sets the size.

Also if you’re using a lot of UI components you may want to try using tables instead of adding components directly to the stage because tables give you a lot more flexibility for arranging components. Here is a great tutorial on using table layouts: