Reputation: 133
I wanna center my Label component in Horizontal Layout (I'm working on navigation bar) but I still want to have hamburger menu button aligned to the left side of the screen,
I tried to use
navbar.setComponentAlignment(myLabel, Alignment.MIDDLE_CENTER);
on my Horizontal Layout but this don't work, it only center in verticaly,
What can I do to achive that?
Upvotes: 1
Views: 327
Reputation: 4967
Vaadin Label is by default 100% wide, so you need to set its width to undefined to center it:
myLabel.setWidthUndefined();
Of course, your HorizontalLayout
must be 100% wide (it's undefined by default).
Upvotes: 2