需要用于“内联块"的模拟.从scene2d.ui中的CSS [英] Need an analog for "inline block" from CSS in scene2d.ui

查看:58
本文介绍了需要用于“内联块"的模拟.从scene2d.ui中的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以使用scene2d.ui创建类似于Morrowind的项目列表的小部件?也就是说,您可以在其中放置固定大小的元素,然后将它们堆叠在一行(或一列)中,直到它们按宽度/高度填充父容器为止,以便在此之后将它们堆叠在下一行中/列?

Is there a way to create a widget like Morrowind's items list using scene2d.ui? That is, a container where you can put fixed-sized elements and they would stack up in a row (or in a column) until they fill the parent container by width/height, so after that they'd stack up in the next row/column?

在图像中您可以看到滚动,但是我仍然接受不允许滚动的答案.另外,我知道CSS中的内联块元素不会垂直堆叠(就像在Morrowind中那样),这只是我能想到的最接近的类比.

In the image you can see scrolling, but I'd still accept an answer that doesn't allow scrolling. Also I'm aware that inline block elements in CSS don't stack vertically (like they do in Morrowind), that's just the closest analogy I can come up with.

推荐答案

我制作了一组Horizo​​ntalFlowGroup和VerticalFlowGroup小部件来执行这种布局.

I made a set of HorizontalFlowGroup and VerticalFlowGroup widgets to perform that type of layout.

以下是其中的来源: https://github.com/MobiDevelop/maps-editor/blob/master/maps-editor/src/com/mobidevelop/maps/editor/ui/

Here's the source of them: https://github.com/MobiDevelop/maps-editor/blob/master/maps-editor/src/com/mobidevelop/maps/editor/ui/

如果将Horizo​​ntalFlowGroup放入具有垂直滚动的ScrollPane中,它将填充宽度,然后移至下一行,从而允许垂直滚动.如果将VerticalFlowGroup放置在具有水平滚动的ScrollPane中,它将填充高度并移至下一列,从而允许水平滚动.无论哪种情况,如果您为子窗口小部件使用统一的大小,它们将全部对齐为网格.

If you put the HorizontalFlowGroup in a ScrollPane with vertical scroll, it will fill the width then move to the next row, allowing vertical scrolling. If you put a VerticalFlowGroup in a ScrollPane with horizontal scrolling, it will fill the height and move to the next column, allowing for horizontal scrolling. In either case, if you use a uniform size for the child widgets, they will all align as a grid.

这篇关于需要用于“内联块"的模拟.从scene2d.ui中的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆