环境:
- 瓦丁 7.6.2
- 除了标题之外,目前还没有自定义 CSS 规则
- 默认主题到位:'valo'。
简而言之
我在显示垂直滚动条时遇到间距问题。让我展示一些图片来演示这个问题:
左边正确,右边错误。
描述
当没有显示滚动条时,间距(填充)正确显示在左侧和右侧水平(参考红色框)。但是一旦滚动条可见,右侧的组合框和滚动条之间的间距似乎消失了(将每张图片左侧的红色笔划称为测量线)。
但是,如果我在包含 Combobox 的 GridLayout 上添加边距(右),则边距会保持不变,并且在出现滚动条时会按预期运行。
细节
涉及的单个组件的设置如下:
--- Panel rightSection -------------------------
| |
| --- VerticalLayout componentContainer ------ |
| | | |
| | --- CustomComponent componentWrapper --- | |
| | | | | |
| | | --- GridLayout grid ---------------- | | |
| | | | | | | |
| | | | --- Label headline ------------- | | | |
| | | | | | | | | |
| | | | -------------------------------- | | | |
| | | | | | | |
| | | | --- ComboBox combobox ---------- | | | |
| | | | | | | | | |
| | | | -------------------------------- | | | |
| | | | | | | |
关键设置如下:
rightSection.setSizeFull(); // Panel
componentContainer.setSizeFull(); // VerticalLayout
// the CustomComponent for being able to show the vertical scrollbars
// as there is another component at the bottom of the
// componentContainer which has to be
// excluded of the vertical scrollbars
// therefore, in the constructor
CustomComponent(Component content) {
addStyleName("v-scrollable");
setCompositionRoot(content);
setHeight(100, Unit.PERCENTAGE);
setWidth(100, Unit.PERCENTAGE);
content.setSizeUndefined();
content.setWidth(100, Unit.PERCENTAGE);
}
// make the customComponent take full space inside its parent
componentContainer.setExpandRatio(componentWrapper, 1);
headline.setWidth(100, Unit.PERCENTAGE);
combobox.setWidth(100, Unit.PERCENTAGE);
最后
如何保留 GridLayout 内的组件和垂直滚动条(如果存在)之间的空间?
任何时候,任何提示都值得赞赏:)
干杯,欺负