2009-11-04 29 views
1

我有下面的應用程序,我試圖把一個滾動條放在TabNavigator內部,最好是在最裏面的Vbox上,但滾動條總是在面板上結束。是否有某種財產可以控制這種情況?我認爲身高= 100%會控制它,但似乎並不奏效。控制哪個VBox獲取滾動條

樣本在這裏。您可以在上面查看源代碼: VBox Sample

這裏是無論如何來源:

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" viewSourceURL="srcview/index.html"> 
    <mx:Panel width="400" height="400"> 
     <mx:TabNavigator width="100%" height="100%" creationPolicy="all"> 
      <mx:VBox label="Tab 1" width="100%" height="100%"> 
       <mx:ViewStack width="100%" height="100%"> 
        <mx:VBox width="100%" height="100%"> 
         <mx:Text width="100%" height="500" text="This box is taller than the Panel, but the scrollbar is on the window." /> 
        </mx:VBox> 
       </mx:ViewStack> 
      </mx:VBox> 
     </mx:TabNavigator>  
    </mx:Panel> 
</mx:Application> 

回答

3

我發現正確的解決方案是將箱子上的minheight設置爲0.當未定義minheight時,箱子將嘗試保持在它的測量高度。通過設置minheight,你可以告訴盒子縮小是可以的。

1

我已經在過去的這個問題,解決的辦法是有點靠不住的,但希望這有助於:

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> 
    <mx:Panel width="400" height="400" verticalScrollPolicy="off"> 
     <mx:TabNavigator width="100%" height="100%"> 
      <mx:VBox id="container" label="Tab 1" width="100%" height="100%"> 
       <mx:ViewStack width="100%" height="{container.height - 20}"> 
        <mx:VBox width="100%" height="100%"> 
         <mx:Text width="100%" height="500" text="This box is taller than the Panel, but the scrollbar is on the window." /> 
        </mx:VBox> 
       </mx:ViewStack> 
      </mx:VBox> 
     </mx:TabNavigator>  
    </mx:Panel> 
</mx:Application> 

Flex似乎在98%的時間內正確計算動態組件尺寸,但有時我們需要「按摩」邏輯。

當您查看佈局層次結構(如上所示)時,您只需將父容器(在本例中爲Tab1)命名爲數據綁定,然後使用該容器的height屬性進行尺寸調整。 (你也不要需要在面板上明確說明verticalScrollPolicy =「關閉」,但我如果用的好辦法:P)

請注意,您可以需要從給定的高度減去位或您的滾動條將低於組件邊界;)

+0

這是一個非常天才的解決方案,這是一個非常糟糕的bug。儘管我不需要從視圖堆疊高度中減去20。沒有它就渲染得很好。 – greggreg 2009-11-04 16:49:07

+0

謝謝...這工作很好。我不需要20像素的偏移...也許你需要它,因爲你有「容器」或什麼的填充。 – Osman 2009-11-04 17:35:28

+0

我正在使用FB3 for Linux ...所以有可能渲染對我來說是有點關閉的) 很高興它適合你雖然:D – 2009-11-04 17:43:30