Label can take the size of the containing string?

ui

#1

Hi guys,

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

Thank you,
Catalin


#2

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


#3

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();
grid.add(text);
grid.add(suffix);

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


#4

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.

Gaëtan


#5

Thank you Gaëtan.

It worked with Flow container.