2013-06-11 51 views
1

我想在滾動條中放置多個列表(每個列表不滾動)。我在下面做的工作,但每個列表後面有一個巨大的隨機差距。我已經檢查過renderers.Pending,沒有任何東西導致差距。我注意到它只發生在我將verticalScrollPolicy設置爲關閉時。我不想將它設置爲開啓,否則列表本身將會滾動。Flex:將多個列表放在滾動條中

<s:Scroller height="80%" width="100%"> 
      <s:VGroup width="100%"> 
       <s:Label bottom="5" width="100%" styleName="normalWhite" text="Heading 1" textAlign="left" fontSize="18" /> 
       <s:List id="pendingList1" 
         width="100%" 
         includeIn="pending" 
         dataProvider="{Info}" contentBackgroundAlpha="0" 
         itemRenderer="renderers.Pending" 
         styleName="customList" alternatingItemColors="[#13237d]" 
         selectionColor="#009de0" 
         dragEnabled="false" 
         dragMoveEnabled="false" 
         dropEnabled="false" 
         verticalScrollPolicy="off"> 
        <s:layout> 
         <s:VerticalLayout horizontalAlign="justify" gap="1"/> 
        </s:layout> 
       </s:List> 

       <s:Label bottom="5" width="100%" styleName="normalWhite" text="Heading 2" textAlign="left" fontSize="18" /> 
       <s:List id="pendingList2" 
         width="100%" 
         includeIn="pending" 
         dataProvider="{Info}" contentBackgroundAlpha="0" 
         itemRenderer="renderers.Pending" 
         styleName="customList" alternatingItemColors="[#13237d]" 
         selectionColor="#009de0" 
         dragEnabled="false" 
         dragMoveEnabled="false" 
         dropEnabled="false" 
         verticalScrollPolicy="off"> 
        <s:layout> 
         <s:VerticalLayout horizontalAlign="justify" gap="1"/> 
        </s:layout> 
       </s:List> 
      </s:VGroup> 
</s:Scroller> 
+0

嘗試將所有'List'的'height'設置爲'100%'。 – NINCOMPOOP

+0

這只是切斷了每個列表中的項目。 – Julia

+0

我沒有將其設置爲100%,因此所有項目都將顯示爲不滾動每個列表。然後滾動器應該允許用戶滾動瀏覽所有列表和他們的項目。 – Julia

回答

0

嗯,我試着模擬你的問題,但我沒有得到它。正如你所說,我的代碼工作正常。

test.mxml

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)"> 
    <fx:Script> 
     <![CDATA[ 
      import mx.collections.ArrayCollection; 
      import mx.events.FlexEvent; 

      private var Info:ArrayCollection = new ArrayCollection(["num 1","num 2","num 3","num 4","num 5","num 6","num 7","num 8","num 9","num 10"]); 

      protected function application1_creationCompleteHandler(event:FlexEvent):void 
      { 
       // TODO Auto-generated method stub 
       Info.addAll(new ArrayCollection(["num 1","num 2","num 3","num 4","num 5","num 6","num 7","num 8","num 9","num 10"])); 
       Info.addAll(new ArrayCollection(["num 1","num 2","num 3","num 4","num 5","num 6","num 7","num 8","num 9","num 10"])); 
       Info.addAll(new ArrayCollection(["num 1","num 2","num 3","num 4","num 5","num 6","num 7","num 8","num 9","num 10"])); 
       Info.addAll(new ArrayCollection(["num 1","num 2","num 3","num 4","num 5","num 6","num 7","num 8","num 9","num 10"])); 
       Info.addAll(new ArrayCollection(["num 1","num 2","num 3","num 4","num 5","num 6","num 7","num 8","num 9","num 10"])); 
       Info.addAll(new ArrayCollection(["num 1","num 2","num 3","num 4","num 5","num 6","num 7","num 8","num 9","num 10"])); 
       Info.addAll(new ArrayCollection(["num 1","num 2","num 3","num 4","num 5","num 6","num 7","num 8","num 9","num 10"])); 
       Info.addAll(new ArrayCollection(["num 1","num 2","num 3","num 4","num 5","num 6","num 7","num 8","num 9","num 10"])); 

      } 

     ]]> 
    </fx:Script> 
    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 

    <s:Scroller height="80%" width="100%"> 
     <s:VGroup width="100%"> 
      <s:Label bottom="5" width="100%" styleName="normalWhite" text="Heading 1" textAlign="left" fontSize="18" /> 
      <s:List id="pendingList1" 
        width="100%" 

        dataProvider="{Info}" contentBackgroundAlpha="0" 
        itemRenderer="renderers.Pending" 
        styleName="customList" alternatingItemColors="[#13237d]" 
        selectionColor="#009de0" 
        dragEnabled="false" 
        dragMoveEnabled="false" 
        dropEnabled="false" 
        > 
       <s:layout> 
        <s:VerticalLayout horizontalAlign="justify" gap="1"/> 
       </s:layout> 
      </s:List> 

      <s:Label bottom="5" width="100%" styleName="normalWhite" text="Heading 2" textAlign="left" fontSize="18" /> 
      <s:List id="pendingList2" 
        width="100%" 

        dataProvider="{Info}" contentBackgroundAlpha="0" 

        styleName="customList" alternatingItemColors="[#13237d]" 
        selectionColor="#009de0" 
        dragEnabled="false" 
        dragMoveEnabled="false" 
        dropEnabled="false" 
        > 
       <s:layout> 
        <s:VerticalLayout horizontalAlign="justify" gap="1"/> 
       </s:layout> 
      </s:List> 
     </s:VGroup> 
    </s:Scroller> 
</s:Application> 

renderers.Pending

<?xml version="1.0" encoding="utf-8"?> 
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" 
       autoDrawBackground="true"> 

    <s:Label text="{data}"/> 

</s:ItemRenderer> 

請不要找編碼標準。這裏太糟糕了。 我正在使用Flash Builder 4 & sdk版本是4.1

+0

我正在使用Flash Builder 4.7,Flex 4.6和AIR SDK 3.4。我在iOS模擬器中遇到此錯誤/錯誤。 – Julia

+0

我認爲你使用'IconItemRenderer'作爲'renderers.Pending'。改爲使用'ItemRenderer'。它會解決你的問題。 – Asad

+0

不,我正在使用ItemRenderer標籤。 – Julia

0

設置variableRowHeight =「false」工作並擺脫隨機空白。但是,現在所有列表項的高度都是最高的高度。這是我猜想的臨時解決方案。

0

將VGroup上的間隙設置爲0