【发布时间】:2015-11-07 21:21:05
【问题描述】:
我希望有一个ScrollPane,在Button 上方有两个Labels,它始终 位于屏幕底部。如果这些标签内有这么多文本,这工作正常,滚动是可能的。但是如果只有几行,则按钮会停留在 ScrollPane 的正下方,因此可能会发生 Button 位于屏幕中间的情况。
这是我的代码:
Table container = new Table();
container.setFillParent(true);
container.top();
Table table = new Table();
ScrollPane scrollPane = new ScrollPane(table);
scrollPane.setOverscroll(false, false);
Label label1 = new Label(text1, labelStyle);
Label label2 = new Label(text2, labelStyle);
label2.setWrap(true);
Button button = new Button(buttonStyle);
table.add(label1).pad(paddingText);
table.row();
table.add(label2).pad(0, paddingText, 0, paddingText).width(stage.getViewport().getWorldWidth() - 2 * paddingText);
container.add(scrollPane);
container.row();
container.add(button).pad(paddingButton).bottom();
stage.addActor(container);
应该是这样的:
【问题讨论】:
-
看看
Cell#fill和Cell#expand方法:table.add(...).fillY().expandY(); -
完美运行!将其添加为答案,我会接受。
标签: java user-interface layout libgdx scene2d