Reputation: 1011
In the sample given below there are three Label
components, each having an icon image. The bounding boxes of the images are minimal (thus the image's horizontal line is at the bottom border). I would like to align those images so that their horizontal lines are on the same level as the baselines of the texts. How can I achieve this?
edit: when applying the FlowLayout BASELINE approach I get the following result:
Note: I intentionally put the image on the right side to show that somehow a "upper basline" instead of the actual baseline is used.
edit:
when I change vAlign to BOTTOM I get the following result:
Upvotes: 2
Views: 46
Reputation: 52760
Label
doesn't support that directly as it center aligns the image by default when it's on the left. The solution is to use two labels for each entry:
Label text = new Label("Text");
Label icon = new Label(image);
Container cnt = Container.encloseIn(new FlowLayout(LEFT, BASELINE),
text, icon);
Upvotes: 1