I am adding an image and a label to a HorizontalPanel. The image is vertically aligned to the center, but the text in the label is always aligned to the top.
I am looking for a way to make the text appear in the middle of the label (and thus in the middle on the panel).
I am adding an image and a label to a HorizontalPanel. The image is vertically aligned to the center, but the text in the label is always aligned to the top.
I am looking for a way to make the text appear in the middle of the label (and thus in the middle on the panel).
Share Improve this question asked Dec 17, 2012 at 18:28 Erik SapirErik Sapir 24.8k29 gold badges86 silver badges144 bronze badges 1- If you know the size of the text, you can set the top of the text to be 50% of the parent, then use a negative margin to offset it upwards half of the height of the text. – NickD Commented Dec 17, 2012 at 21:49
2 Answers
Reset to default 5myPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
Use alignment on horizontal panel like below code does.
panel.setCellHorizontalAlignment( image, HasHorizontalAlignment.ALIGN_CENTER );
panel.setCellHorizontalAlignment( label, HasHorizontalAlignment.ALIGN_CENTER );
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745036221a4607534.html
评论列表(0条)