Xamarin.Forms Relative Layout Xaml

1

To try to create a screen that has an image at the end of the screen and above it is the login buttons, type this here:

withtheyellowrectanglebelowandthebuttonsaboveit.butIcannotdoit,seetheresult:

andhere'sthecode:

<ContentPagexmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="vanhack.mobile.StartPageView"
         BackgroundImage="bg.png">
<StackLayout>
    <Label Text="Tentando Fazer um layout bonito!" VerticalOptions="Center"></Label>
    <StackLayout VerticalOptions="EndAndExpand">
        <RelativeLayout >
            <Button Text="Log In With e-mail" Command="{Binding EmailLoginCommand}"></Button>
            <Image Source="Rectangle2.png"  />
            <Image Source="linkedin.png"  />
        </RelativeLayout>

    </StackLayout>
</StackLayout>

How to settle?

    
asked by anonymous 25.08.2016 / 03:39

2 answers

1

The image is overlaying the button, just add the button after the image.

<RelativeLayout >
   <Image Source="Rectangle2.png"  />
   <Image Source="linkedin.png"  />
   <Button Text="Log In With e-mail" Command="{Binding EmailLoginCommand}"></Button>
</RelativeLayout>
  

See the result:


IrecommendusingGridifyouwanttopositionthebuttonataspecificlocationonthescreen.Buttoncolorusedintheexample:

<ButtonText="Log In With e-mail" Command="{Binding EmailLoginCommand}" BackgroundColor="#F2C248"/>
    
28.08.2016 / 04:29
0

Dude, do not use this relative layout, try to use the grid that is much better.

The grid has a behavior similar to the table where you control the amount of rows and columns and can use the same span in the html

                                                                            

    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto" />  isso serve para ajustar a largura de acordo com o tamanho do campo
      <ColumnDefinition Width="*" />isso serve para preencher todo o espaço
      <ColumnDefinition Width="40" />
    </Grid.ColumnDefinitions>

                  

    
03.02.2017 / 23:02