我已经在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)
请告诉我有更好的方法.