Default Skin LibGDX?

When it comes to UI in libGDX, you will find its very different than what you would have used before (yaml, json, xml, UI Builders, etc).

Table Layout - This is how Scene2d UI is structured and formatted. The link you have provided is a great tutorial, but as you have come to realize, you need a skin to do most things.

LibGDX Skin - consists of 3 things, a texture pack image, a texture pack file, and a Json to set up the styles. You can also generate them programmatically like you are doing, but I find it much easier to simply load them from a file and use. If you want to learn more about how to make skins, or edit them, etc follow this link: Skins.

Now, back to the exception you are getting. This is because the skin you have created doesn't have the json used to describe the styles for various UI elements. In the case of the above exception, the label inside of the text field doesn't have a default style.

What you can simply do is use the template provided in the tests folder:

  1. Atlaspack File
  2. Json File
  3. Atlaspack Image
  4. Font Image
  5. Font File

Put these files in the assets folder of your android project. And then you can easily load this skin with one line of code:

Skin uiSkin = new Skin(Gdx.files.internal("uiskin.json"));

This will have the missing piece of information to make your TextField object, as well as a bunch of other default styles:

com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: {
    default: { font: default-font, fontColor: white },
}

Hopefully this helps get you started. There are a number of other little things so don't be afraid to look over the Scene2d.UI article on the wiki for more information.

Note: You can use gdx-tools artifact to be able to use the default UI skin out-of-the-box (can be quite useful for very small/simple applications, for debugging, when you're in a real rush to have the UI visible, etc).


Or if you want to create your very own, Raleus made up a skin editor, Pretty friendly Ui, simple to use, results are awesome https://github.com/raeleus/skin-composer Once you navigate threw it a bit you understand much more about skins and how tu use'em