我用这段代码构建了一个UI:
// Trying to fix the layout by setting the defaults for the next row.
layout.row().expand(false, false).fill(false).colspan(4);
Label playerLabel = new Label(Settings.playerName + " " + playerScore, skin, "defaultWhite");
layout.add(playerLabel).colspan(1);
Label historyLabel = new Label(getHistory(), skin, "defaultWhite");
historyLabel.setAlignment(2);
layout.add(historyLabel).colspan(2).expandX();
Label cpuLabel = new Label(cpuScore + " CPU", skin, "defaultWhite");
layout.add(cpuLabel).colspan(1);
layout.row();
我希望它可以使播放器和cpu得分上升到两边,并且历史标签可以得到剩余的空间,但这就是它的作用:
我在这里做错什么了吗?我看不出是什么错误。
如果您想看一下其余的代码,它在github上,或者问一下,我将提供更多的上下文。
最佳答案
而不是使用一个表进行整个布局,请尝试在每个内部表都是一行的情况下嵌套表。这消除了全部合并的需要,并且您可以创建列并按需要布置每个行表,而不影响其他行。