HBox 子组件分隔符

发布于 2024-09-12 00:23:37 字数 119 浏览 2 评论 0原文

如何在 HBox 子组件周围添加分隔线?

就像如果我选择 borderstyle 作为 hbox 的实体,问题是子组件之间的线,例如文本组件,我可以以有效的方式显示它,而不仅仅是将 HBox 添加到每个元素。

How could I add separating line around HBox children component?

Like if I choose borderstyle as solid for the hbox, the problem is the line between the children component, like text components, who could I show it in efficient way, not just adding HBox to each element.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屋顶上的小猫咪 2024-09-19 00:23:37

HBox 只是一个具有水平布局的子项的盒子 - 它实际上在这些子项之间没有垂直线,因此您将无法使用边框或 HBox 上的任何内容。

您最好的选择可能是在每个子组件之间添加 VRule 组件,例如:

<mx:HBox width="100%" borderColor="#000000" borderStyle="solid">
    <mx:Image />
    <mx:VRule height="100%" strokeColor="#000000" strokeWidth="1"/>
    <mx:Image />
    <mx:VRule height="100%" strokeColor="#000000" strokeWidth="1"/>
    <mx:Image />
</mx:HBox>

您可以根据需要调整 VRule 和 HBox 边框样式以保持一致。我能想到的唯一其他选项是在每个子组件周围放置边框,而 HBox 上没有边框(可能需要子填充,具体取决于您的组件),将所有组件嵌入 HBox 内的 Box 组件中就像您建议的那样,或者做一些完全疯狂的事情,例如使用 Horizo​​ntalList 并将组件嵌入到与边框大小一致的自定义项目渲染器中。

就我个人而言,我只会使用 VRule 分隔符并继续。我宁愿在孩子身上加倍投入,也不愿将我感兴趣的所有组件都放在 HBox 中更深一层的家庭层中。如果您需要从变量数组等生成 HBox 子级,那么您可能需要将每个子级放入 Box 中并使用 Repeater 或其他东西。一些更多细节将有助于获得更具体的答案。

A HBox is just a box with a horizontal layout of children - it doesn't actually have vertical lines running between those children, so you're not going to be able to use borders or anything on the HBox.

Your best bet is probably adding VRule components in between each child component, something like:

<mx:HBox width="100%" borderColor="#000000" borderStyle="solid">
    <mx:Image />
    <mx:VRule height="100%" strokeColor="#000000" strokeWidth="1"/>
    <mx:Image />
    <mx:VRule height="100%" strokeColor="#000000" strokeWidth="1"/>
    <mx:Image />
</mx:HBox>

You can adjust the VRule and HBox border styles to be consistent however you like. The only other options I can think of are to put borders around each child component with no border on the HBox (may need child padding depending on your components), embed all your components in Box components within the HBox like you suggest, or doing something completely crazy like using a HorizontalList and embedding your components in a custom item renderer that is a consistent size with a border.

Personally I'd just use VRule separators and move on. I'd rather double up on children than have all my components of interest one family level deeper in the HBox. If you need to generate your HBox children from a variable array or suchlike, then you may want to put each one in a Box and use a Repeater or something. Some more detail would help for more specific answers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文