![](/img/trans.png)
[英]How to get rid of wasted space in SWT ScrolledComposite when the scrollbars are not shown
[英]ScrolledComposite showing no scrollbars when set to expand
我的問題是,如果我的滾動復合材料有
scrolledWrapper.setExpandHorizontal(true);
scrolledWrapper.setExpandVertical(true);
它在整個ViewPart上正確擴展,但如果我收縮View,則不會出現滾動條。
如果我沒有設置展開,則滾動條會出現,但滾動的復合材料內的整個復合材料不會展開。
GridLayout gridLayout = new GridLayout(1, true);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
ScrolledComposite scrolledWrapper = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolledWrapper.setLayout(gridLayout);
// if set the scrollbars dont appear but the composite expand on the whole view
scrolledWrapper.setExpandHorizontal(true);
scrolledWrapper.setExpandVertical(true);
scrolledWrapper.setLayoutData(gridData);
scrolledWrapper.setBackground(Display.getCurrent().getSystemColor(BG_COLOR));
有人知道如何設置Composite以擴展到我的整個視圖,但是當視圖縮小時還會顯示滾動條嗎?
我找到了一個解決方案:
您需要設置最小尺寸。 復合材料需要知道它的尺寸是小的
scrolledWrapper.setMinSize(wrapper.computeSize(SWT.DEFAULT, SWT.DEFAULT));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.