2011-04-07 97 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}"

这将图像的最大高度设为与您的应用程序高度相同。