环境:
简而言之
显示垂直滚动条时我的间距有问题。 让我展示一些图片来证明这个问题:
在左侧更正,在右侧不正确。
描述
如果未显示滚动条,则水平左侧和右侧正确显示间距(填充)(参考红色框)。 但是一旦滚动条变得可见,组合框和滚动条之间右侧的间距似乎消失了(指的是每张图片左侧的红色笔划作为测量线)。 / p>
但是,如果我在包含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内部组件与垂直滚动条(如果存在)之间的空间?
任何时候,任何提示都表示赞赏:)
干杯, 欺