Flex的 - 水平HBox中的垂直位置儿童
-
09-09-2019 - |
题
我有一个自定义HBox中作为左右....
公共类MyBar延伸HBox中{
public function MyBar() {
super();
this.height = 65;
this.percentWidth = 100;
var newButton:Button = new Button();
//.....
newButton.y = 20;
var spacer1:Spacer = new Spacer();
spacer1.percentWidth = 50;
var spacer2:Spacer = new Spacer();
spacer2.percentWidth = 50;
this.addChild(spacer1);
this.addChild(newButton);
this.addChild(spacer2);
}
}
这显示在HBox中的中心的按钮,但该按钮被对准到箱的顶部,我想它是在中心。
我敢肯定,我之前简单,如设置y值有这个工作。但似乎并没有现在的工作。我使用SDK 3.3
任何人有任何线索,为什么我有这个困难吗?
谢谢!
解决方案
设置Y作为HBox中控制所述y位置将无法工作。如果您想让所有的按钮被放置在HBox中的你需要verticalAlign设置为中间的中间
在代码,这将是
setStyle("verticalAlign", "middle");
不隶属于 StackOverflow