【发布时间】:2015-04-18 00:04:11
【问题描述】:
使用 Grails 2.3.9 和 Vaadin 插件 7.3.9
class MyUI extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) {
VerticalLayout layout = new VerticalLayout()
layout.setMargin(true)
SignInForm signInForm = new SignInForm()
layout.addComponent(signInForm)
layout.setComponentAlignment(signInForm, Alignment.MIDDLE_CENTER)
layout.setSizeFull()
setContent(layout)
}
}
自定义组件
class SignInForm extends CustomComponent {
Panel p = new Panel()
public SignInForm() {
p.setSizeUndefined()
Label label = new Label("test");
p.setContent(label);
setCompositionRoot(p);
}
}
看起来是这样的:
如何将自定义组件水平居中?
【问题讨论】:
-
我的回答有帮助吗?