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

RelativeLayout constraint doesn't work without rotation first

$
0
0

Hi,

I'm new to Xamarin and I would like to make a simple trick: display two buttons on the bottom right of the screen . But this only works after having rotated the screen once . Why ?

How to force to do it directly ?

` RelativeLayout m__rLayout = new RelativeLayout();
public App() {
// The root page of your application
m__rLayout.BackgroundColor = Color.Gray;

    // button stack
        StackLayout l__buttonLayout = new StackLayout();
        l__buttonLayout.BackgroundColor = Color.Black;
        l__buttonLayout.Orientation = StackOrientation.Horizontal;

        Button l__prev = new Button() { Text="<<" };
        l__prev.Clicked += prevImage;
        Button l__next = new Button() { Text=">>" };
        l__next.Clicked += nextImage;
        l__buttonLayout.Children.Add(l__prev);
        l__buttonLayout.Children.Add(l__next);


        m__rLayout.Children.Add(l__buttonLayout,
            xConstraint : Constraint.RelativeToParent((parent) => { return parent.Width - l__buttonLayout.Width; }),
            yConstraint : Constraint.RelativeToParent((parent) => { return parent.Height - l__buttonLayout.Height; })
            );

        MainPage = new ContentPage { Content = m__rLayout };
    }

`

Thanks!


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>