在定义 绝对值 定位时, 需要定义 子类 控件 的 横坐标x、纵坐标y 的 像素值。
Flex 默认 子类 位置是 (0,0)。
[img]/upload/attachment/115808/fd1688a4-d861-31ef-9999-d51d4781152c.png[/img]
未定义 绝对值
[img]/upload/attachment/115810/5d174979-3f82-3868-8cdc-ff5e9c8ea85d.png[/img]
使用 绝对值 定位
Flex 默认 子类 位置是 (0,0)。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="280" height="240">
<!-- 定义 画布 容器 -->
<mx:Canvas borderStyle="solid" width="100%" height="100%" backgroundColor="white">
<!-- 定义 两个 按钮,按钮A 大小 大于 按钮B -->
<mx:Button id="buttonA" label="按钮 A" width="150" height="50"/>
<mx:Button id="buttonB" label="按钮 B"/>
</mx:Canvas>
</mx:Application>[img]/upload/attachment/115808/fd1688a4-d861-31ef-9999-d51d4781152c.png[/img]
未定义 绝对值
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="280" height="240">
<!-- 定义 画布 容器 -->
<mx:Canvas borderStyle="solid" width="100%" height="100%" backgroundColor="white">
<!-- 定义 两个 按钮,按钮A 大小 大于 按钮B -->
<mx:Button id="buttonA" label="按钮 A" width="150" height="50" x="5" y="5"/>
<mx:Button id="buttonB" label="按钮 B" x="5" y="80"/>
</mx:Canvas>
</mx:Application>[img]/upload/attachment/115810/5d174979-3f82-3868-8cdc-ff5e9c8ea85d.png[/img]
使用 绝对值 定位
本文通过实例展示了如何在Flex中使用绝对定位来精确控制子组件的位置。通过设置x和y属性,可以将按钮放置在画布上的指定位置。
922

被折叠的 条评论
为什么被折叠?



