In my libGDX application I am using the scene2d.ui
classes to render my game's GUI. One of the things I render via these classes is a dialog window with a background image set. I have created the uiskin.json
file accordingly, and the dialog is shown correctly with the background image.
There is one catch however: The size of the dialog window is exactly set to fit the text elements, but not more. If not much text is shown on the dialog, then the background image is rendered much smaller than it really is.
I can override or hard-code the window size by overriding getPrefWidth()
and getPrefHeight()
in my custom Dialog
class. But that does not feel right.
My question: What is the correct way to set a scene2d.ui
dialog with a background image to be as large as that background image, regardless of how much text is being shown?