Sergey
Sergey

Reputation: 963

Flex mx:image fit in screen

I have some layout with image, I want that layout fit in screen automatically (thats why i am using 100%), but when I load big image, it goes beyond screen (actually i can set mx:Image maxHeight="" but this value not will be the same for different screen resolutions)

my layout sample:

    <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>

update: the best solution for me

<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" />

Upvotes: 0

Views: 1794

Answers (2)

J_A_X
J_A_X

Reputation: 12847

You need to set the height/width to all containers to be 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>

Upvotes: 2

Jason Towne
Jason Towne

Reputation: 8050

Assuming you want the Image to be the same size as your application (and assuming you're using Flex 4), you can use:

maxHeight="{FlexGlobals.topLevelApplication.height}"

This will set the max height of your Image to the same height as your application.

Upvotes: 1

Related Questions