Label can take the size of the containing string?



Hi guys,

Do you know if the Label can take the size of the containing string?

Thank you,


Hi Catalin,

By default the Label is always returning a size large enough to display its string to its parent. However depending on the container the label is included in, the Label may be resized to fit in the layout (resulting in the string not being completely displayed).

So what container are you using?

Gaëtan for MicroEJ


Hi Gaëtan,

Thank you for the quick answer.

I have two labels into a Grid container but I have also tried with a List. It’s a text and his suffix.
I have something like this.

Label text = new Label("Text");
Label suffix = new Label("Suffix");

Grid grid = new Grid();

The issue is that the distance between the text and his suffix is to big.


Hi again,

In this case the label will be centered inside each part of the grid:

|   x   |   x   |

Using a Flow container you could have something like this:

| x | x |       |

Or even a centered version:

|   | x | x |   |

Hope it’ll help.



Thank you Gaëtan.

It worked with Flow container.