2011-04-19 32 views
1

我試圖自動調整s:Group內的子組的大小。孩子們是另一個:集團和一個H:集團。每個的百分比寬度分別爲10%和90%。問題是,當其中一個組的大小被調整(在皮膚中使用轉換和旋轉組合)時,另一個組不會自動調整大小以填充空間?Flex 4調整組中的組

不應該自動執行此操作嗎?還是我必須編碼?

<s:Group 
    id="listsGroup" 
    width="100%" 
    height="255" 
    > 

    <s:Label text="LIST WITH HEADER TEST" styleName="h1" /> 

    <s:Group 
     id="listsGroupSavedSearches" 
     width="10%" 
     height="255" 
     > 
     <components1:ListWithHeader 
      id="categories11" 
      dataProvider="{listModel}" 
      headerLabel="Saved Searches" 
      allowMultipleSelection="true" 
      top="10" bottom="0" 
      left="0" width="10%" 
      /> 
    </s:Group> 

    <s:HGroup left="160" width="90%" height="150" top="50" gap="6"> 
     <components1:ListWithHeader 
      id="categories1" 
      dataProvider="{listModel}" 
      headerLabel="Category1 " 
      allowMultipleSelection="true" 
      width="100%" 
      height="150" 
      /> 
     <components1:ListWithHeader 
      id="categories2" 
      dataProvider="{listModel}" 
      headerLabel="Category2" 
      allowMultipleSelection="true" 
      width="100%" 
      height="150" 
      /> 
     <components1:ListWithHeader 
      id="categories3" 
      dataProvider="{listModel}" 
      headerLabel="Category3" 
      allowMultipleSelection="true" 
      width="100%" 
      height="150" 
      /> 
    </s:HGroup> 
</s:Group> 
+0

我之前有過類似的問題,可能會嘗試刪除第二個%的寬度?或將其設置爲100%?我知道,有時當flex繪製的東西他們不會以我期望的方式去做 – Mike 2011-04-19 13:32:23

+0

您可能想嘗試用'HGroup'替換頂部的'Group'。我相信'Group'組件是基於'x''y' coord的,並且不像'HGroup'或'VGroup'那樣流暢。 – 2011-04-19 15:15:33

+0

Garbage 2011-04-21 12:50:51

回答

0

接近這樣的事情最好的辦法是綁定到Flex組件生命週期方法,特別是updateDisplayList()。 UpdateDisplayList()用於定位和調整您的孩子。它有兩個參數,即組件的高度和寬度。然後,您可以根據組件的高度和寬度編寫算法來確定您的孩子的大小和位置。

MXML在引擎蓋下做到了這一切,有種黑魔法;但如果您自己編寫佈局代碼,您將獲得更多控制權。