HBox 子组件分隔符
如何在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HBox
只是一个具有水平布局的子项的盒子 - 它实际上在这些子项之间没有垂直线,因此您将无法使用边框或 HBox 上的任何内容。您最好的选择可能是在每个子组件之间添加
VRule
组件,例如:您可以根据需要调整 VRule 和 HBox 边框样式以保持一致。我能想到的唯一其他选项是在每个子组件周围放置边框,而 HBox 上没有边框(可能需要子填充,具体取决于您的组件),将所有组件嵌入 HBox 内的
Box
组件中就像您建议的那样,或者做一些完全疯狂的事情,例如使用HorizontalList
并将组件嵌入到与边框大小一致的自定义项目渲染器中。就我个人而言,我只会使用 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: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 aHorizontalList
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 aRepeater
or something. Some more detail would help for more specific answers.