1

内側のサイズを取得する可能性はあるのだろうかと思っていました

com.google.gwt.user.client.ui.ScrollPanel

GWT のオブジェクト? スクロールバーをアクティブにせずに、空のスペースに正確に収まる ScrollPanel の子を作成したいと思います。ScrollPanel は次のように初期化されます。

[@Abhijith Nagaraja の回答後に更新を開始]

public void onModuleLoad() {

    Window.setMargin("0px");

    TabLayoutPanel tabs = new TabLayoutPanel(30, Unit.PX);

    //attach the tab panel to the body element
    RootPanel.get(null).add(tabs);

    //set the TabLayoutPanel to full size of the window.
    String width = (Window.getClientWidth()) + "px";
    String height = (Window.getClientHeight()) + "px";
    tabs.setSize(width, height);

    //create the scroll panel and activate the scroll bars
    ScrollPanel scrollPanel = new ScrollPanel(new Button("a second button"));
    scrollPanel.getElement().getStyle().setOverflowX(Overflow.SCROLL); 
    scrollPanel.getElement().getStyle().setOverflowY(Overflow.SCROLL);

    //attach the scroll panel to the DOM
    tabs.add(scrollPanel, "tab1");

    System.out.println(scrollPanel.getOffsetWidth());       // --> 0
    System.out.println(scrollPanel.getOffsetHeight());      // --> 0

}

【更新終了】

理由: 動的なビジュアライゼーション (後でスクロールバーが必要になる) を初期化して、見栄えがよくなり、ScrollPanel を後で追加するのを避けたいと考えています。

4

2 に答える 2

0

ScrollPanel sp = new ScrollPanel();

...

int innerWidth = sp.getOffsetWidth() - sp.getElement().getScrollWidth();

...

注: 上記のコードは、scrollPanel が画面にアタッチされている場合にのみ使用できます。つまり、レンダリングする必要があります。

于 2013-03-16T06:53:41.610 に答える
0
DOM.setStyleAttribute(scrollpanel.getElement(), "maxHeight", mMainHeight + "px");;
于 2013-04-17T06:30:17.513 に答える