Page orientation in xamarin

0

I'm starting to program using xamarin forms, I created a registration screen, but when I change the orientation of the screen to horizontal it does not activate the scroll and the buttons are hidden. Home Follow the code on the screen:

<StackLayout>

    <StackLayout>
        <Label FontSize="Medium">Nome Fornecedor:</Label>
        <Entry x:Name="NomeForecedor"></Entry>
        <Label FontSize="Medium">Cidade Fornecedor:</Label>
        <Entry x:Name="CidadeForecedor"></Entry>
        <Label FontSize="Medium">CNPJ:</Label>
        <Entry x:Name="Cnpj"></Entry>
        <Label FontSize="Medium">Estado:</Label>
        <Entry x:Name="EstadoForecedor"></Entry>
    </StackLayout>

    <StackLayout Orientation="Horizontal">
        <Button x:Name="btnSalvar"   
                BackgroundColor="Azure" 
                Text="Salvar" 
                HorizontalOptions="FillAndExpand"></Button>
        <Button x:Name="btnCancelar" 
                BackgroundColor="Azure"
                Text="Cancelar" 
                HorizontalOptions="FillAndExpand"></Button>
    </StackLayout>


</StackLayout>

Note: I'm using a ContentPage .

    
asked by anonymous 26.05.2017 / 15:05

2 answers

0

You have to add a ScrollView in your Page.

Place the code you want to 'scroll' within the ScrollView tag.

Here is an example with your code:

<StackLayout>

 <ScrollView>
   <StackLayout>
       <Label FontSize="Medium">Nome Fornecedor:</Label>
       <Entry x:Name="NomeForecedor"></Entry>
       <Label FontSize="Medium">Cidade Fornecedor:</Label>
       <Entry x:Name="CidadeForecedor"></Entry>
       <Label FontSize="Medium">CNPJ:</Label>
       <Entry x:Name="Cnpj"></Entry>
       <Label FontSize="Medium">Estado:</Label>
       <Entry x:Name="EstadoForecedor"></Entry>
   </StackLayout>

   <StackLayout Orientation="Horizontal">
        <Button x:Name="btnSalvar"   
            BackgroundColor="Azure" 
            Text="Salvar" 
            HorizontalOptions="FillAndExpand"></Button>
        <Button x:Name="btnCancelar" 
            BackgroundColor="Azure"
            Text="Cancelar" 
            HorizontalOptions="FillAndExpand"></Button>
      </StackLayout>
 </ScrollView>

</StackLayout>

If you want to show ScrollView only when the screen changes orientation, you can use the example below:

07.06.2017 / 13:18
0

Maybe you should use a Relative Layout because depending on it may not be legal for the user to scroll on a signup screen. link

    
08.06.2017 / 21:13