Stick Layout in Xamarin Forms to bottom

后端 未结 7 1135
星月不相逢
星月不相逢 2020-12-12 19:11

I\'m making an application in Xamarin forms but I have some trouble sticking a layout to the bottom of the device. I thought an AbsoluteLayout would work, but I cannot grasp

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 19:30

    I figured it out:

    I used a StackLayout, which contains the three main Childeren

     var stack = new StackLayout {
                    Children =
                        {
    
                            _header,
                            _grid,
                            _footer,
    
                        }
                };
    

    And then you should add the header as a AbsoluteLayout and remember to use the:

     {
        AbsoluteLayout.SetLayoutFlags(_imageYouWantToUse, AbsoluteLayoutFlags.PositionProportional);
        AbsoluteLayout.SetLayoutBounds(_imageYouWantToUse, new Rectangle(x, y, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
    _headerAbsLayout.Children.Add(_imageYouWantToUse);
        }
    

    And for the main grid or the main content, you should use a grid inside a StackLayout, so that you're sure that the layout is vertical (Orientation, is the right one to use here).

    And do the same thing for the footer and i guess you're good to go

提交回复
热议问题