Apache flex 你知道如何设置布局吗?
我想用两个按钮控制列表左/右一个元素 但我对如何布局这些组件有些困惑 我使用“requestedColumnCount=“6””设置列表宽度,因此在设计模型中 我只知道这个列表可以显示6个元素,但我不知道它的宽度 所以我用“HGroup”来设置布局,主代码是这样的Apache flex 你知道如何设置布局吗?,apache-flex,list,layout,Apache Flex,List,Layout,我想用两个按钮控制列表左/右一个元素 但我对如何布局这些组件有些困惑 我使用“requestedColumnCount=“6””设置列表宽度,因此在设计模型中 我只知道这个列表可以显示6个元素,但我不知道它的宽度 所以我用“HGroup”来设置布局,主代码是这样的 <s:HGroup x="214" y="216"> <s:Group> <s:layout> <s:VerticalLay
<s:HGroup x="214"
y="216">
<s:Group>
<s:layout>
<s:VerticalLayout />
</s:layout>
<s:Button label="←"
click="button1_clickHandler(event)"/>
</s:Group>
<s:Group>
<component:SmoothScrollingList dataProvider="{myProvider}"
itemRenderer="myitemdrender.FriendPageItemRender"
id="friendPageList"
mouseDown="friendPageList_mouseDownHandler(event)">
<component:layout>
<s:HorizontalLayout requestedColumnCount="6"
useVirtualLayout="true"/>
</component:layout>
</component:SmoothScrollingList>
</s:Group>
<s:Group>
<s:Button label="→"
click="button2_clickHandler(event)"/>
</s:Group>
</s:HGroup>
您可以看到,我使用一个HGroup和三个group来确定组件应该在哪里
快结束了,但我仍然有问题,如何设置这两个按钮的时间
中间位置
我试着用
<s:layout>
<s:VerticalLayout horizontalAlign="center"/>
</s:layout>
在第一组布局中,但似乎不起作用
<s:HGroup x="214" y="216" id="parentGroup">
<s:Group id="childOneGroup">
<s:Button label="←" top="{parentGroup.height*0.3}"/>
</s:Group>
<s:Group>
<component:SmoothScrollingList dataProvider="{myProvider}"
itemRenderer="myitemdrender.FriendPageItemRender"
id="friendPageList">
<component:layout>
<s:HorizontalLayout requestedColumnCount="6" useVirtualLayout="true"/>
</component:layout>
</component:SmoothScrollingList>
</s:Group>
<s:Group>
<s:Button label="→" top="30"/>
</s:Group>
</s:HGroup>
我的另一个问题是:
这是使用这么多组和hgroup来确定位置的好方法吗?有吗
还有别的好办法吗
非常感谢。在这些情况下,您应该使用属性,以进一步清理代码;然后,这些附加属性所属的位置也可见。例如,对于第一组,只需编写:
<s:Group layout="VerticalLayout">
<s:Button label="←" click="button1_clickHandler(event)"/>
</s:Group>
然而,在您的情况下,仅为内部的一个不同元素使用一个额外的组元素是没有意义的
<s:HGroup x="214" y="216" verticalAlign="middle">
<s:Button label="←" click="button1_clickHandler(event)"/>
<component:SmoothScrollingList
id="friendPageList" dataProvider="{myProvider}"
itemRenderer="myitemdrender.FriendPageItemRender"
mouseDown="friendPageList_mouseDownHandler(event)">
<component:layout>
<s:HorizontalLayout requestedColumnCount="6" useVirtualLayout="true"/>
</component:layout>
</component:SmoothScrollingList>
<s:Button label="→" click="button2_clickHandler(event)"/>
</s:HGroup>
对不起,也许我的描述不太清楚 我的黄金可能是一些像这样的用户界面() 但在degin模型中,我不知道列表的高度/剂量。我想要这个 按钮为列表高度的30%。我尝试使用一个包含所有3个组件的HGroup 似乎不起作用
<s:HGroup x="214" y="216" id="parentGroup">
<s:Group id="childOneGroup">
<s:Button label="←" top="{parentGroup.height*0.3}"/>
</s:Group>
<s:Group>
<component:SmoothScrollingList dataProvider="{myProvider}"
itemRenderer="myitemdrender.FriendPageItemRender"
id="friendPageList">
<component:layout>
<s:HorizontalLayout requestedColumnCount="6" useVirtualLayout="true"/>
</component:layout>
</component:SmoothScrollingList>
</s:Group>
<s:Group>
<s:Button label="→" top="30"/>
</s:Group>
</s:HGroup>
但如果我使用三个组(每个组分属于一个组)并更改按钮“顶部”
值设置为{parentGroup.height*0.3},它正在工作。对于混乱的代码感到抱歉。下次我会注意使用三组//按钮← // 列表//按钮→ 因为我想把这个组件放在列表中间。例如:list heiht=100,那么第一个按钮的位置应该是(0,50),但现在第一个按钮的位置是(0,0)。我尝试使用,但它不起作用,只有当我设置准确的值时才起作用,例如:。嗯,HGroup应该自动将所有子元素分布在水平面上。“代码”> VistaAlalIG=“中间”应该把所有元素放在HGROW的高度中间(这样可能是HGROW只是不够高,无法将其分发到MID)。我还没有安装Flex4,所以我不能自己测试它,但是HGroup,作为Flex3中HBox的等价物,应该是这样工作的。