Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

(Label and StackLayout) fill all the space inside the stack layout

$
0
0

Hello

As you can see in the image, I can't let the label fill all the space needed and my text is been cut off, I have tried a lot of different things (horizontal and vertical options.fill and fill and expand, even use a wrap layout) but i can't achieve the visual effect that i want without using height and width request, any ideas?

My code is build like this:

Color bgColor = (section.SubFields[index].ValidationType == FieldValidationType.Required) ? Color.FromRgb(217, 83, 79) : Color.White;
            Label fl = new Label
            {
                TextColor = Color.Black,
                Text = section.SubFields[index].Label,
                //LineBreakMode = LineBreakMode.WordWrap,
                VerticalOptions = LayoutOptions.Fill,
                HorizontalOptions = LayoutOptions.Fill,
                YAlign = TextAlignment.Center,
                Font = Font.OfSize("Helvetica neue", fontSize).WithAttributes(FontAttributes.Bold),
                BackgroundColor = Color.Red
            };

            Image arrowImg = new Image
            {
                Source = ImageSource.FromFile("arrow_right.png"),
                HeightRequest = 15
            };
                case FormFieldType.MultiLineText:
                    Label mlLabel = new Label
                    {
                        YAlign = TextAlignment.Center,
                        WidthRequest = 100,
                        TextColor = Color.Black,
                        HorizontalOptions = LayoutOptions.EndAndExpand,
                        Text = section.SubFields[index].DefaultValue,
                        LineBreakMode = LineBreakMode.TailTruncation,
                        XAlign = TextAlignment.End,
                    };

                    StackLayout mlStack = new StackLayout
                    {
                        HorizontalOptions = LayoutOptions.Fill,
                        VerticalOptions = LayoutOptions.Fill,
                        Orientation = StackOrientation.Horizontal,
                        Padding = 10,
                        //HeightRequest = 40,
                        //BackgroundColor = Color.White,
                        BackgroundColor = Color.Blue,
                        Children = { fl, mlLabel, arrowImg }
                    };

                    stack2.Children.Add(mlStack); //Stack2 is my main container
                    break;

Viewing all articles
Browse latest Browse all 58056

Trending Articles