2011-04-07 101 views
0

我有一些圖像佈局,我希望自動佈局適合屏幕(這就是爲什麼我使用100%),但是當我加載大圖像,它超出屏幕(實際上我可以設置MX:圖片maxHeight = 「」 但是這個值不是將是不同的屏幕分辨率相同)Flex mx:圖像適合屏幕

我的佈局示例:

<s:VGroup>    
     <s:BorderContainer borderStyle="solid" width="100%" height="100%> 
      <s:Scroller left="2" right="2" top="2" bottom="2"> 
       <s:Group id="group"> 
        <mx:Image id="currImg" /> 
       </s:Group> 
      </s:Scroller> 
     </s:BorderContainer> 
     <!-- ..... --> 
     </s:VGroup> 

更新:對我來說,最好的解決辦法

<s:VGroup width="100%" height="100%">    
    <s:BorderContainer borderStyle="solid" width="100%" height="100%"> 
    <s:Scroller left="2" right="2" top="2" bottom="2"maxWidth="{mx.core.FlexGlobals.topLevelApplication.widht}" maxHeight="{mx.core.FlexGlobals.topLevelApplication.height}"> 
     <s:Group id="group" > 
     <mx:Image id="currImg" /> 

回答

2

您需要將所有容器的高度/寬度設置爲100%。

<s:VGroup width="100%" height="100%">    
    <s:BorderContainer borderStyle="solid" width="100%" height="100%"> 
     <s:Scroller left="2" right="2" top="2" bottom="2"> 

        <mx:Image id="currImg" width="100%" height="100%" scaleContent="true" /> 
     </s:Scroller> 
    </s:BorderContainer> 
</s:VGroup> 
1

假設你想要的Image是大小爲您的應用程序相同的(假設你正在使用Flex 4),你可以使用:

maxHeight="{FlexGlobals.topLevelApplication.height}"

這將圖像的最大高度設爲與您的應用程序高度相同。