how to Fill Image fullscreen in stackLayout ?

ShahabuddinVansiwalaShahabuddinVansiwala USMember ✭✭
edited November 2015 in Xamarin.Forms

how to Fill Image fullscreen in stackLayout in Xamarin ?

I can't set Image in fit to stacklayout

.XAML File Code

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Test.FirstLoadScreen" >

  <StackLayout Padding="0" BackgroundColor="Yellow">
    <Image Source="ic_splash.png" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" > </Image>
  </StackLayout>
</ContentPage>

Screenshot of Output Android and Window Phone....

I want to fit Image in Background.

Best Answer

Answers

  • Finally I solved problem using below code....

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                           x:Class="Your.Namespace.Views.LoginView"
                 Title="{Binding Title}"
                 BackgroundImage="BackgroundImage.png">
      <StackLayout>
        <!-- Your stuff goes here -->
      </StackLayout>
    </ContentPage>
    

    I have set background Image as fit to screen using above code....

    BackgroundImage="BackgroundImage.png"

  • SujaBSujaB USUniversity ✭✭✭

    Hi

    I have a view with two stack layout. In the first stack layout i need to provide a background image and two buttons on left and right side of stack layout and a label.But using stack layout i can only provide background color instead of image .Could anyone please help me to solve this?.

  • SethBooneSethBoone USMember

    @Matthew.4307 said:
    In case anybody wants a solution to the original code it was probably this Image Aspect="Fill"

    This is exactly what I needed! Thank you for following through on the original question.

Sign In or Register to comment.