2014-02-24 59 views
0

我是GWT和uiBinder的新手,當窗口縮小以顯示具有固定大小的項目時,我需要顯示滾動條。如何使用DockLayoutPanel進行滾動?

UiBinder.xml

<clui:DockLayoutPanel unit='EM'> 
     <clui:center> 
      <clui:TabLayoutPanel barHeight="2" barUnit="EM" width="100%" height="100%" ui:field="tabs" /> 
     </clui:center> 
</clui:DockLayoutPanel> 

Java代碼

@UiField TabLayoutPanel tabs; 

interface IndexUiBinder extends UiBinder<Widget, Index> { 
} 

public doc() { 
    initWidget(uiBinder.createAndBindUi(this)); 

    tabs.add(new FirstDoc(), "First"); 
    tabs.add(new SecondDoc(), "Second"); 
} 

我嘗試添加屬性的CSS時,出現滾動,而不是工作

body { 
    overflow:scroll; 
} 

謝謝你的他LP。

回答

0

您需要使用ScrollPanel。您將它添加(並且僅限它!)到您的選項卡,然後其他所有內容都會進入ScrollPanel。

+0

謝謝,我必須爲每個選項卡添加scrollPanel?因爲我試過這個但不工作:ScrollPanel sp = new ScrollPanel(tabs); – TimeIsNear

+1

你必須添加ScrollPanel在DockLayoutPanel和TabLayoutPanel,或TabLayoutPanel和每個選項卡的窗口小部件之間(如:'tabs.add(新ScrollPanel(新FirstDoc()),「第一」)') –

+1

通常情況下,添加一個ScrollPanel每個標籤內(托馬斯的建議),從而使標籤始終保持可見,而標籤滾動的內容時必要的。 –