Having problems with the layout widget 'Contai

2019-08-27 23:19发布

I'm building a menu for my game and I'm stuck.

When I position a Container with it's setPosition function and add a Button to the container with setFillParent set to true the button's position isn't set to the same position as the container.

The button size matches the size of the Container but its position is wrong. When I don't set setFillParent to true the position of the button within the container is right but the size is wrong.

Here is the code, pretty simple:

Container container = new Container(exitButton);

exitButton.setFillParent(true/false);

Here is an image that ilustrate this, left image has setFillParent set to true and the right image does not.

The green hightlight on the image is the container, the [X] image is the exitButton.

1条回答
时光不老,我们不散
2楼-- · 2019-08-27 23:29

Ok, I figured it out, calling container.fill() before setting the containers size and position somehow solves the problem. No idea why, but it solves it.

查看更多
登录 后发表回答