如何让Label的文字垂直居中?
我一一尝试了这些方法:在资源编辑器中将 BgAlign 属性设置为 CENTER , myLabel.getStyle().setBackgroundAlignment(Style.BACKGROUND_IMAGE_ALIGN_CENTER);
但标签的文本未居中垂直。
那么如何让Label的文字垂直居中呢?
下图显示了标签文本的实际对齐方式:
I tried one by one each of these methods : setting the BgAlign property to CENTER in the Resource Editor , myLabel.getStyle().setBackgroundAlignment(Style.BACKGROUND_IMAGE_ALIGN_CENTER);
but the text of the Label is not centered vertically.
So how to make Label's text centered vertically ?
The following image shows the actual alignement of the Label's text :
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
标签垂直对齐仅不受其相对于图标的定位的支持。
据我记得您对每个支持垂直对齐的条目都使用
FlowLayout
,请参阅FlowLayout.setValign(Component.CENTER)
。Label vertical alignment is unsupported only its positioning in relation to an icon.
As far as I recall you are using
FlowLayout
for every entry which does support vertical alignment seeFlowLayout.setValign(Component.CENTER)
.