I need to use a Grid
screen (to organize the Entries and Buttons) and AbsoluteLayout
(to have the ball in the middle of the screen). If this is done the screen layout becomes deformed (image below). If you shoot AbsoluteLayout
the screen gets organized as it should.
MyneedistouseGrid
andAbsoluteLayout
withouthavingthedeformations.
FollowtheXAMLcode:
<?xmlversion="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FoodSuppy.Login"
Title="FoodSuppy">
<AbsoluteLayout>
<Grid>
<Grid.RowDefinitions>
<!-- Define as linhas -->
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<BoxView Grid.Row="0"
BackgroundColor="Bisque"/>
<BoxView Grid.Row="1"
BackgroundColor="Accent"/>
<BoxView Grid.Row="2"
BackgroundColor="Aqua"/>
<BoxView Grid.Row="3"
BackgroundColor="Beige"/>
<BoxView Grid.Row="4"
BackgroundColor="Blue"/>
<!-- Entry's -->
<Entry Grid.Row="2"
x:Name="entryEmail"
Text="[email protected]"
FontSize="Small"
VerticalOptions="StartAndExpand"/>
<Entry Grid.Row="2"
x:Name="entrySenha"
IsPassword="True"
Text="123456"
FontSize="Small"
VerticalOptions="CenterAndExpand"/>
<!-- Botões -->
<Button Grid.Row="3"
Text="Cadastro"
Clicked="btnCadastrarUserAsync"
TextColor="White"
HorizontalOptions="Start"
VerticalOptions="StartAndExpand"
FontSize="Small"
BackgroundColor="DodgerBlue"
Margin="0"/>
<Button Grid.Row="3"
x:Name="btnAcessar"
Clicked="btnAcessar_Clicked"
HorizontalOptions="Center"
VerticalOptions="StartAndExpand"
Text="Acessar"
TextColor="White"
FontSize="Small"
BackgroundColor="DodgerBlue"
Margin="0"/>
<Button Grid.Row="3"
Text="Sair"
Clicked="Sair_Clicked"
HorizontalOptions="End"
VerticalOptions="StartAndExpand"
TextColor="White"
FontSize="Small"
BackgroundColor="DodgerBlue"
Margin="0"/>
</Grid>
<!-- Loading -->
<StackLayout IsVisible="{Binding IsLoading}"
AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
AbsoluteLayout.LayoutFlags="All"
BackgroundColor="DodgerBlue"
Opacity="0.5">
<!-- Loading -->
<ActivityIndicator x:Name="actInd"
IsRunning="{Binding IsLoading}"
IsVisible="{Binding IsLoading}"
Color="DarkBlue"
HeightRequest="60"
WidthRequest="60"
BackgroundColor="Transparent"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand">
</ActivityIndicator>
</StackLayout>
</AbsoluteLayout>
</ContentPage>