开发者

Scaling an image in a scroller resizes the scroller when relative dimension are set to the scroller

开发者 https://www.devze.com 2022-12-22 13:15 出处:网络
I would like to position relatively a scroller in my application like below. When I scale the image, I resize the scroller...

I would like to position relatively a scroller in my application like below. When I scale the image, I resize the scroller...

<s:Scroller width="50%" height="50%" >
  <s:Group>
   <mx:Image 
       id="img"
       source="sample.jpg"
       />
  </s:Group>
 </s:Scroller>

If I set absolute dimension to the scroller like below, it does not resize (behaviour I want)

 <s:Scroller width="400" height="400" >
  <s:Group&g开发者_JAVA技巧t;
   <mx:Image 
       id="img"
       source="sample.jpg"
       />
  </s:Group>
 </s:Scroller>

.. but my intention is to position the scroller relatively to other components. Any explanations/solutions?


This is because the Group doesn't have a size, so it gets a measured size and becomes whatever it's collective children's sizes are. Then the Scroller has a ScrollerLayout which sizes the Scroller: If it has an explicit width/height, it uses that, otherwise it uses it's content sizes. Flex ignores percent sizing it seems.

Check out the ScrollerLayout source, at the updateDisplayList method. It doesn't take into account the Scroller's percent sizes :/.

Hope that helps, Lance


Thanks, it works (but only by setting the percents in the Scroller). For example:

<s:HGroup width="50%" height="50%">


<s:Scroller width="100%" height="100%" >
    <s:Group>
        <mx:Image 
            id="img"
            source="sample.jpg"
            />
    </s:Group>
</s:Scroller>

<s:Button label="Zoom+" click="{zoomPlus()}">
</s:Button>
</s:HGroup>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号