Display a square image in an AbsoluteLayout

cmillauriauxcmillauriaux FRMember ✭✭
edited July 2016 in Xamarin.Forms

Hi everyone,

I want to make a ContentView with three elements : an image (100px * 100px), an another image (10px * 10px) positionned at the center of the first image and a label. I made a Stacklayout with an AbsoluteLayout for images and a Label.

My question is : how to parameter the AbsoluteLayout to display the image in a square ? The AbsoluteLayout have to take full width available, and images are square, so it have to take only the same size in height.

My current code :

<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyProject.Controls.SignCounter">
  <StackLayout>
    <AbsoluteLayout x:Name="signImage" BackgroundColor="Blue">
       <Image />
       <Image />
    </AbsoluteLayout>
    <Label x:Name="signTitle" HorizontalTextAlignment="Center" VerticalTextAlignment="Start" TextColor="Gray" FontSize="15"/>
  </StackLayout>
</ContentView>
Sign In or Register to comment.