Page orientation in the Xamarin

Asked

Viewed 186 times

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.
Follow the screen code:

<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>

Obs: I’m wearing a Contentpage.

2 answers

0

You have to add one Scrollview on your Page.

Put the code you want to scroll inside the tag Scrollview.

Below 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 article example below:

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.