Quantcast
Channel: Question and Answer » libgdx
Viewing all articles
Browse latest Browse all 434

libGdx Window .pack() not working

$
0
0

I’m trying to make a window, then use the pack method to get the right size, but the window maximizes instead. Here’s my code:

private Table buildOptionsWindowLayer() {
    winOptions = new Window("Options", skinLibgdx);
    // (...) building some widgets

    Gdx.app.log(TAG, "pref width is " + winOptions.getPrefWidth());
    // displays: "pref width is 247.0"

    winOptions.pack();

    // move the window
    winOptions.setPosition(Constants.VIEWPORT_GUI_HEIGHT - winOptions.getWidth() - 50, 50);
    return winOptions;
}

The window ends up with a width of 800.0f. Why?

What it is supposed to render:
enter image description here

What it does render:
enter image description here


Viewing all articles
Browse latest Browse all 434

Trending Articles