在Flex中调整容器大小的最佳方法是只遵从父容器的显式维度 [英] Best way to size containers in Flex to obey ONLY parent containers' explicit dimensions

查看:141
本文介绍了在Flex中调整容器大小的最佳方法是只遵从父容器的显式维度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

近一年来,我一直在使用Flex来解决这个问题,而且每次我都会研究一个快速的黑客解决方案。我想看看有没有人有更好的主意。



这是一个问题的条件:

  | ------容器------------ | 
| explicitHeight:400(或其他)
| |
| | -------- VBox ------- | |
| | percentHeight:100 | |
| | | |
| | | -Repeater ------ | | |
| | |可能| | |
| | |很多东西。 | |
| - | - | --------------- | --- | --- |

问题在于,与我想要发生的情况相反,VBox总是会扩展以容纳它的内容,而不是坚持其父母的显式高度,并创建一个滚动条。

我的解决方案已经硬编码的引用到父(或者显示列表的距离,我们需要去找一个明确的设置值,而不是一个百分比)。

我甚至考虑过在实用类:

pre preublic $ {
preublic $ {
$ )return comp.explicitHeight;
if(comp.parent is UIComponent)return
getFirstExplicitHeightInDisplayList(UIComponent(comp.parent));
else返回0;
}

请告诉我有更好的方法。



















默认情况下,VBox容器的大小足够大,以保持原始大小的图像,如果禁用布局更新,使用缩放效果放大图像,或使用移动效果重新定位图像,图像可能会扩展超过VBox容器的边界。
将autoLayout属性设置为false,所以VBox容器不会随着图像大小调整大小。增长到一个大小,以便它超出了VBox容器的边界,容器添加滚动条,并在图像的边界剪辑。



我希望能帮到你。

I've been running into this problem with Flex for nearly a year, and each time I work up a quick hack solution that works for the time being. I'd like to see if anyone has a better idea.

Here are the conditions of a problem:

|------Container  ------------|
|  explicitHeight:  400 (or whatever)
|                             |
|  |-------- VBox  -------|   |
|  |  percentHeight: 100  |   | 
|  |                      |   |
|  |  |-Repeater------|   |   |
|  |  | Potentially   |   |   |
|  |  | a lot of stuff.   |   |
|--|--|---------------|---|---|

The problem is that, contrary to what I would like to happen, the VBox will ALWAYS expand to accommodate the content inside it, instead of sticking to the explicit height of its parent and creating a scroll bar.

My solution has been to hard code in a reference to the parent (or however far up the display list we need to go to find an explicitly set value as opposed to a percentage).

I've even considered using this in a utility class:

public static function getFirstExplicitHeightInDisplayList(comp:UIComponent):Number{
    if (!isNaN(comp.explicitHeight)) return comp.explicitHeight;
    if (comp.parent is UIComponent) return    
         getFirstExplicitHeightInDisplayList(UIComponent(comp.parent));
    else return 0;
}

Please tell me there's a better way.

解决方案

You have to use the "autoLayout" parameter on the VBox as documentation say:

"By default, the size of the VBox container is big enough to hold the image at it original size. If you disable layout updates, and use the Zoom effect to enlarge the image, or use the Move effect to reposition the image, the image might extend past the boundaries of the VBox container.

You set the autoLayout property to false, so the VBox container does not resize as the image resizes. If the image grows to a size so that it extends beyond the boundaries of the VBox container, the container adds scroll bars and clips the image at its boundaries.

I hope that will help you.

这篇关于在Flex中调整容器大小的最佳方法是只遵从父容器的显式维度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆