Flex 4 调整组内组的大小
我正在尝试自动调整 s:Group 中子级的大小。子级是另一个 s:Group 和一个 H:Group。每个的百分比宽度分别为 10% 和 90%。问题是,当调整其中一个组的大小(使用皮肤中的过渡和旋转组合)时,另一组不会自动调整大小以填充空间?
Flex 不应该自动执行此操作吗?或者我必须编写这个代码吗?
<s:Group
id="listsGroup"
width="100%"
height="255"
>
<s:Label text="LIST WITH HEADER TEST" styleName="h1" />
<s:Group
id="listsGroupSavedSearches"
width="10%"
height="255"
>
<components1:ListWithHeader
id="categories11"
dataProvider="{listModel}"
headerLabel="Saved Searches"
allowMultipleSelection="true"
top="10" bottom="0"
left="0" width="10%"
/>
</s:Group>
<s:HGroup left="160" width="90%" height="150" top="50" gap="6">
<components1:ListWithHeader
id="categories1"
dataProvider="{listModel}"
headerLabel="Category1 "
allowMultipleSelection="true"
width="100%"
height="150"
/>
<components1:ListWithHeader
id="categories2"
dataProvider="{listModel}"
headerLabel="Category2"
allowMultipleSelection="true"
width="100%"
height="150"
/>
<components1:ListWithHeader
id="categories3"
dataProvider="{listModel}"
headerLabel="Category3"
allowMultipleSelection="true"
width="100%"
height="150"
/>
</s:HGroup>
</s:Group>
I am trying to automatically resize the children within an s:Group. The children are another s:Group and a H:Group. Each have a percentage width of 10% and 90% each. The problem is that when one of the groups is resized (using a transition and rotation combination in the Skin), the other group does not automatically resize to fill the space?
Shouldn't Flex do this automatically? or do I have to code this?
<s:Group
id="listsGroup"
width="100%"
height="255"
>
<s:Label text="LIST WITH HEADER TEST" styleName="h1" />
<s:Group
id="listsGroupSavedSearches"
width="10%"
height="255"
>
<components1:ListWithHeader
id="categories11"
dataProvider="{listModel}"
headerLabel="Saved Searches"
allowMultipleSelection="true"
top="10" bottom="0"
left="0" width="10%"
/>
</s:Group>
<s:HGroup left="160" width="90%" height="150" top="50" gap="6">
<components1:ListWithHeader
id="categories1"
dataProvider="{listModel}"
headerLabel="Category1 "
allowMultipleSelection="true"
width="100%"
height="150"
/>
<components1:ListWithHeader
id="categories2"
dataProvider="{listModel}"
headerLabel="Category2"
allowMultipleSelection="true"
width="100%"
height="150"
/>
<components1:ListWithHeader
id="categories3"
dataProvider="{listModel}"
headerLabel="Category3"
allowMultipleSelection="true"
width="100%"
height="150"
/>
</s:HGroup>
</s:Group>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理此类问题的最佳方法是结合 Flex 组件生命周期方法,特别是 updateDisplayList()。 UpdateDisplayList() 用于调整子项的位置和大小。它有两个参数,即组件的高度和宽度。然后,您可以编写一个算法,根据组件的高度和宽度来调整子组件的大小和位置。
MXML 在幕后完成这一切,有点像黑魔法。但如果您自己编写布局代码,您将获得更多控制权。
The best way to approach something like this is to tie into the Flex Component lifecycle methods, specifically updateDisplayList(). UpdateDisplayList() is used to position and size your children. It has two parameters, the height and width of your component. You can then write an algorithm to size and position your children based on the component's height and width.
MXML does this all under the hood, kind of in a black magic sort of way; but you'll gain more control if you write the layout code yourself.