我有一个GWT对话框,如下所示:
public class FooDialog extends DialogBox {
public FooDialog() {
setText("Foo Dialog");
VerticalPanel outer = new VerticalPanel();
outer.setBorderWidth(3);
outer.setSize("400px", "200px");
outer.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
outer.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE);
Button cancelButton = new Button("Cancel", new ClickHandler() {
public void onClick(ClickEvent event) {
hide();
}
});
HorizontalPanel buttons = new HorizontalPanel();
buttons.setBorderWidth(3);
buttons.add(cancelButton);
outer.add(buttons);
setWidget(outer);
}
}
由于某种原因,“按钮”面板不遵循horizontalAlignment设置;它粘在外板的左侧。但是,它确实遵循vertialAlignment设置。有任何想法吗?谢谢!
答案 0 :(得分:4)
表不尊重父级的水平对齐属性。相反,设置左和右;子表的右边距为“auto”。
buttons.getElement()。getStyle()。setProperty(“marginLeft”,“auto”); buttons.getElement()。getStyle()。setProperty(“marginRight”,“auto”);