0

How do i add logo to center of the Xaml Form, i am starting out Xamarin.

My xaml code looks something like this :

    <StackLayout Spacing="20" Padding="50" VerticalOptions="Center">  
        <Entry Placeholder="Mail id"></Entry>  
        <Entry Placeholder="Password" IsPassword="True"></Entry>  
        <Button Text="Log In" TextColor="White" BackgroundColor="##ff77D065"></Button> </StackLayout>  
</ContentPage>

This works fine, Now i want to see where i can add the logo to the Xaml form, Its cross platform.

I am new to this.

Edit

Trying out something like this

<StackLayout Spacing="20" Padding="50" VerticalOptions="Center">
             VerticalOptions="Center" Padding="10">
    <Image Source="screenimg2.png" x:Name="imgLogo" HeightRequest="150" WidthRequest="150"/>  
    <Entry Placeholder="Mail id"></Entry>  
    <Entry Placeholder="Password" IsPassword="True"></Entry>  
    <Button Text="Log In" TextColor="White" BackgroundColor="##ff77D065"></Button> 
</StackLayout>  
Sam
  • 31
  • 6

1 Answers1

0

You can use an AbsoluteLayout to contain your "background" logo and then the StackLayout, both centered on screen and then place your UI widgets inside the StackLayout to control the order of their placement:

Example (Logo is set to a 25% opacity):

<AbsoluteLayout BackgroundColor="Black">
    <Image Source="logo.png" AbsoluteLayout.LayoutBounds=".5,.5,.75,.75" AbsoluteLayout.LayoutFlags="All" Opacity=".25" />
    <StackLayout AbsoluteLayout.LayoutBounds="1,1,1,1" AbsoluteLayout.LayoutFlags="All" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"  >
        <Label Text="INTRO TO THE WORLD" TextColor="Green" />
        <Entry Text="Some Entry Text" BackgroundColor="Green" />
    </StackLayout>
</AbsoluteLayout>

enter image description here

re: Xamarin.Forms AbsoluteLayout

SushiHangover
  • 73,120
  • 10
  • 106
  • 165