EDIT: I tried to do the following and it worked in my tests:
textfieldstyle.background.setLeftWidth(textfieldstyle.background.getLeftWidth() + 10);
Searching the libgdx API I could not find a way to specify a text add-on inside the TextField component.
As a workaround, you can copy the original TextField source and create a new TextField with a different name, which provides a way to implement the add-on.
Copy the contents of the libgdx text box ( https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/TextField.java?source=cc ) to another file and let's call it MyTextField (as an example). Replace the broken TextField links with the new class name.
Create a new variable called paddingLeft, for example:
public float paddingLeft = 0.0f;
In the draw () method, you can add your addition to the sum to define a new position for the String. Where the code says:
font.draw(batch, displayText, x + bgLeftWidth + textOffset, y + textY + yOffset, visibleTextStart, visibleTextEnd);
replaced by:
font.draw(batch, displayText, x + bgLeftWidth + textOffset + leftPadding, y + textY + yOffset, visibleTextStart, visibleTextEnd);
(note the "+ leftPadding" in the second code)
Then, if you use skins, do not forget to refer to your TextField in the uiskin.json file:
mypackage.MyTextField$TextFieldStyle: { default: { selection: selection, background: textfield, font: default-font, fontColor: white, cursor: cursor } }
and use it in your code:
MyTextField txtTest = new MyTextField("Test", skin); txtTest.leftPadding = 10.0f;
This is not an ideal way, but it will work.