4
votes

When i set StackOrientation.Horizontal for stacklayout and setting 5 labels it displays properly.

enter image description here

But when the number of labels count is increased labels text size reduced and all labels are aligned for available width.

enter image description here

How to display full text for all labels also move label to next line if the labels count exceeds?

3

3 Answers

3
votes

Use WrapLayout instead:

    var layout = new WrapLayout {
                    Orientation = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Fill,
                    Padding = new Thickness (0, padding, 0, padding)
                };
    layout.Children.Add (item);

Result: enter image description here

3
votes

StackLayout with Horizontal orientation will only use "one line".

For that case you should use a GridLayout or WrapLayout (From Xlabs).

In alternative you could use a StackLayout with Horizontal orientation and each Child is a StackLayout with Vertical orientation.

0
votes

Xamarin 3.0 introduced FlexLayout for exactly this use-case. It's based on CSS Flexboxes.