小编Aar*_*ron的帖子

在Flex中调整容器大小的最佳方法是仅服从父容器的显式维度

我已经在Flex中遇到了这个问题将近一年,而且每次我都会使用快速的黑客解决方案.我想看看是否有人有更好的主意.

以下是问题的条件:

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

问题是,与我想要发生的情况相反,VBox将始终扩展以容纳其中的内容,而不是坚持其父级的显式高度并创建滚动条.

我的解决方案是在对父代的引用中进行硬编码(或者在显示列表中我们需要找到明确设置的值而不是百分比).

我甚至考虑在实用程序类中使用它:

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;
}
Run Code Online (Sandbox Code Playgroud)

请告诉我有更好的方法.

apache-flex flash layout

7
推荐指数
2
解决办法
6928
查看次数

标签 统计

apache-flex ×1

flash ×1

layout ×1