Libx GDX可滚动,带有圆形覆盖

时间:2014-10-07 13:02:48

标签: java android libgdx

我是libGDX的新手,尝试使用table layout

实现下图所示的布局

容器表[绿色]由表标题 [蓝色]和ScrollPane 正文 [黑色项目]组成。身体也是一个有各种行的桌子。

我正在尝试将正文部分滚动到"" 标题即可。在开始时, body 的所有项目都应该在适当的填充处可见。

到目前为止的代码:

ScrollPane body = new ScrollPane(bodyTable);
header.add(headerBar).expandX().fillX();    
container.add(header).top().expandX().fillX().row();
container.add(body).fill().expand();

[请注意,剪切中不包含所需的纹理]。

它可以正确滚动,但有一个横向切割标题正文,而我希望有一个更圆的效果。不知道这可以用桌子吗?是否有任何示例/建议可以指出我正确的方向?

enter image description here

2 个答案:

答案 0 :(得分:0)

我想帮助,但我的腹股沟很难理解我,你想要它在一个表格中,例如标题仍然存在,而其他人移动按钮,例如。

http://i.stack.imgur.com/C9cwR.png

1-添加窗口到table和table.row();

2-将其他窗口添加到表格并添加滚动条。

如果那是你的意思,

不会。

答案 1 :(得分:0)

过了一会儿,我设法有了一个正常工作的版本。

在Scene2d中,Stack widget设计为将一个项目叠加在另一个项目上。

层次结构的概述是:

Stack container = new Stack;
// the container is using all the available space 
container.setFillParent(true);  
container.add(body);
container.add(head);
stage.addActor(container);

棘手的部分是在 head body 中定义元素的正确位置。

因此,对于我的实现中的 head ,我有类似的内容:

Table header = new Table();
Table header_container = new Table(skin);

// assign a background behind the header contents
Drawable tableBackground = skin.getDrawable("top_bg");

//some position tweaks to resize the background to the wanted height
tableBackground.setMinHeight(10);
tableBackground.setBottomHeight(30);
tableBackground.setTopHeight(10);
header_container.setBackground(tableBackground);

// headerBar is another table that contains the buttons that are in the header 
header.add(headerBar).expandX().fillX();
header_container.add(header).expandX().fillX();
head.addActor(header_container);

正文是包含表格的ScollPane。内部表定义了Top Padding,因此在开始时完全可见。滚动时,它会在标题部分下面隐藏一点。

它正在工作但感觉涉及太多的嵌套,如果我发现更清洁的解决方案将更新上面的代码。

相关问题