Osman
Osman

Reputation: 1011

CN1 align Label icon with regards to the baseline of its text

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?

enter image description here

edit: when applying the FlowLayout BASELINE approach I get the following result:

enter image description here

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:

enter image description here

Upvotes: 2

Views: 46

Answers (1)

Shai Almog
Shai Almog

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

Related Questions