GWT:我如何将内容集中在面板中? [英] GWT: How do I center content in a panel?
本文介绍了GWT:我如何将内容集中在面板中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用GWT 2.4。我有一个简单的内容视图...
final图片ajaxImage = new图片(loading.gif);
final Grid grid = new Grid(1,2);
grid.setText(0,0,正在加载...);
grid.setWidget(0,1,ajaxImage);
this.container = new FlowPanel();
this.container.add(grid);
rootPanel = new SimplePanel();
rootPanel.add(this.container);
我希望这些内容能够在包含面板中水平和垂直居中,这是一个FlowPanel,如果那很重要。如何做到这一点?
谢谢, - 戴夫
VerticalPanel panelPrincipal3 = new VerticalPanel(); // Esto es el panel central, donde se centra todo
panelPrincipal3.setWidth(100%);
panelPrincipal3.setHeight(100%);
panelPrincipal3.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
panelPrincipal3.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
panelPrincipal3.add(/ * your panel * /); //这里你可以添加任何你想要的,并且应该以
为中心$ / code $ / pre
I'm using GWT 2.4. I have a view with some simple content ...
final Image ajaxImage = new Image("loading.gif");
final Grid grid = new Grid(1, 2);
grid.setText(0, 0, "Loading...");
grid.setWidget(0, 1, ajaxImage);
this.container = new FlowPanel();
this.container.add(grid);
rootPanel = new SimplePanel();
rootPanel.add(this.container);
I would like this content to be centered horizontally and vertically in the containing panel, which is a FlowPanel, if that matters. How do I do that?
Thanks, - Dave
解决方案 I know how to do it in a verticalpanel.
VerticalPanel panelPrincipal3 = new VerticalPanel();//Esto es el panel central, donde se centra todo
panelPrincipal3.setWidth("100%");
panelPrincipal3.setHeight("100%");
panelPrincipal3.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
panelPrincipal3.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
panelPrincipal3.add(/*your panel*/);//here yo add whatever yo want, and should be centered
这篇关于GWT:我如何将内容集中在面板中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文