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

RelativeLayout Children alignment

$
0
0

Hello. I have a problem with centering elements in RelativeLayout.
I want My StackLayout with 3 Labels in in to be centered horizontally and vertically.
For achieving this I'm trying to do something like this:

rl.Children.Add(
textLogo,
Constraint.RelativeToParent(parent => { return (parent.Width - textLogo.Width)/2; }),
Constraint.RelativeToParent(parent => { return (parent.Height- textLogo.Height)/2; })
);
// Where rl is RelativeLayout and textLogo is StaskLayout

But something is wrong. textLogo.Width is -1 for some reason when this code is invokes.

So is there a way to center my textLogo in RelativeLayout?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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