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

Xamarin Forms - RelativeLayout WidthConstraint

$
0
0

I was trying RelativeLayout in Xamarin Forms for the first time.

I was hoping to get the login fields (entries along with login button), in the middle of the screen, also width to be half of its parent.
I am confused, couldn't figure out the problems :
1. StackLayout is not in the center of RelativeLayout
2. StackLayout width to be half of RelativeLayout

    <RelativeLayout HorizontalOptions="FillAndExpand"
                    VerticalOptions="Center" 
                    BackgroundColor="Yellow">

     <StackLayout Orientation="Vertical"  
                  HorizontalOptions="Center"
                  BackgroundColor="Red"
                  RelativeLayout.WidthConstraint="{ConstraintExpression
                     Type=RelativeToParent,
                     Property=Width,
                     Factor=0.5 }" >

            <Entry Placeholder="Client Code" />

            <Entry Placeholder="Tab Code" />

            <Entry Placeholder="User name" />

            <Entry Placeholder="Password" />

            <Button Text="LOGIN" TextColor="White" BackgroundColor="Red" />

        </StackLayout>

    </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>