如何将垂直布局中的标签移动到flex 4.5中的任意位置?
我知道这对于 Flex 专家来说非常简单,但我才刚刚开始。
例如我有这个:
<s:Label id="lbl2"
alpha="0.0"
text="Cute Software Engineer"
color="#ffffff"
fontSize="32" />
我想将我的标签移动到右上角?
我无法将布局更改为基本/绝对布局,因为我希望标签始终位于屏幕中央。几个动画之后,我想将标签移动到右上角。
I know this is very simple for those expert in flex but im just starting out.
For instance i have this:
<s:Label id="lbl2"
alpha="0.0"
text="Cute Software Engineer"
color="#ffffff"
fontSize="32" />
I'd like to move my label say to the upper right?
I can't change my layout to a basic/absolute layout since i want my labels centered in the screen all the time. After a few animations, i'd like to move the label to the upper right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有几个选项(像往常一样!)。显而易见的答案是放弃垂直布局并重构为绝对布局,按照 Harry 的建议使用约束以及 HorizontalCenter 和 VerticalCenter 属性,然后无论何时/无论何时都可以放置元素。
如果您绝对需要保持垂直布局,另一个选择(更复杂)是创建一个包装器(如组)来包装垂直布局的组件。然后从 VerticalLayout 中删除该元素,设置其位置,然后将其添加到包装器中。
我创建了一个小型测试项目来说明第二个选项。单击位于底部的按钮将从垂直布局中删除标签并将其添加到位于右上角的绝对包装器中...您还可以单击“替换”按钮将元素添加回垂直组件...希望这会有所帮助!
There are a couple of options here(as usual!). The obvious answer would be to ditch the vertical layout and refactor for an absolute layout, using constraints and the horizontalCenter and verticalCenter properties as Harry suggested, then position your element however/whenever you want.
If you absolutely need to keep the vertical layout, another option(more convoluted) would be to create a wrapper (like a group) to wrap your vertically laid out component. Then remove the element from the verticalLayout, set it's positioning and then add it to the wrapper.
I've created a small test project to illustrate the second option. Clicking the buttons located at the bottom removes a label from the vertical layout and adds it to the absolute wrapper positioned top right...you can also click the Replace button to add the element back to the vertical component... HOPE THIS HELPS!