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

AbsoluteLayout or RelativeLayout

$
0
0

Hello,

I got some problems with both of these Layouts. I designed a couple of screens, but I cannot seem to understand how both of these layouts needs to be implemented.

I tried to do it with a StackLayout filled with: RelativeLayout - StackLayout - RelativeLayout
But I cannot seem to get the last relativeLayout to align on the bottom of the screen...

Then I thought maybe I need to do it with a AbsoluteLayout, I need to stick it to the bottom of the screen, but there aren't any good examples for it. So maybe you guys can help me out?

The top one I have actually 3 elements (there are 2 showed I know) which I have layed out with the Relative Layout. The green box shows a stacklayout in which I stack a couple of buttons. The Yellow box is the one where I have some troubles. I thought maybe a RelativeLayout works here, but I've got problems with sticking it behind the greenbox, it doesn't seem to work. It appends behind the blue box for some reason. The three colored layouts I stack with a stacklayout behind eachother..

Is this maybe too much, can I put it simpler or? If you guys could help me out, awesome!

image

headerRelativeLayout = new RelativeLayout {
                VerticalOptions = LayoutOptions.Start,
                HeightRequest = logo.Height
            };

            headerRelativeLayout.Children.Add (logo, 
                Constraint.RelativeToParent ((parent) => {
                    return 0;
                }),
                Constraint.RelativeToParent ((parent) => {
                    return 0;
                }));

            headerRelativeLayout.Children.Add (nameLabel,
                Constraint.RelativeToParent ((parent) => {
                    return 0.70 * parent.Width;
                }),
                Constraint.RelativeToParent ((parent) => {
                    return 15;
                }));

            headerRelativeLayout.Children.Add (connectImage,
                Constraint.RelativeToParent ((parent) => {
                    return 0.88 * parent.Width;
                }),
                Constraint.RelativeToParent ((parent) => {
                    return 12;
                }));
        buttonStackLayout = new StackLayout {

                VerticalOptions = LayoutOptions.Start,
                Padding = 50,

                Children = {
                    button1, button2, button3

                }

            };

            footerLayout = new AbsoluteLayout {
                VerticalOptions = LayoutOptions.End,
                HeightRequest = logo.Height
            };

Viewing all articles
Browse latest Browse all 58056

Trending Articles