Qbix Qbix - 5 months ago 28
Java Question

How to set a text padding in a TextField?

enter image description here

I need to set a left-padding of the text inside a TextField.
There is a method

setAlign(Align.TOP | BOTTOM | CENTER)
but I need to hardcode a value so it looks nice.

Here's my current code:

TextField loginField = new TextField("", skin);
TextField passwordField = new TextField("", skin);

loginField.setMessageText("LOGIN");
passwordField.setMessageText("PASSWORD");


I've tried editing the TextFieldStyle, but still with no success.
Thanks for any ideas!

Answer

You can use passwordField.getStyle().background.setLeftWidth method to add left padding.