1
votes

I have a simple File->New Project Xamarin Forms app just created. When the Editor gains focus the navigation bar slides up. Is this a bug, or how do you lock the navigation bar in place and scroll the page content instead?

Runnable source code can be download here. I am observing this behavior on a Samsung Note 3 phone. This doesn't happen in iOS.

https://github.com/JohnLivermore/SampleXamarinApp/tree/funkyNavbar

App.xaml

public partial class App : Application
{
    public App()
    {
        InitializeComponent();

        var mainPage = new MainPage();
        var nav = new NavigationPage(mainPage);

        MainPage = nav;
    }
}

MainPage.xaml

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             Title="Page Title"
             x:Class="SampleApp.MainPage">
    <ScrollView>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Text="Field A:" />
            <Editor Grid.Row="1" HeightRequest="200" />
            <Label Grid.Row="2" Text="Field B:" />
            <Editor Grid.Row="3" HeightRequest="200" />
            <Label  Grid.Row="4" Text="Field B:" />
            <Editor Grid.Row="5" HeightRequest="200" />
            <Label  Grid.Row="6" Text="Field B:" />
            <Editor Grid.Row="7" HeightRequest="200" />
            <Label  Grid.Row="8" Text="Field B:" />
            <Editor Grid.Row="9" HeightRequest="200" />
        </Grid>
    </ScrollView>
</ContentPage>
2
Could you share a screenshot of this behavior so we can understand whats wrongSaamer
NavigationPage just a container for a stack of pages. You only add/remove pages off of the stack and navigate to them!Coder the Great

2 Answers

1
votes

Add the following code in App.cs to make page auto-resizable.

using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
public partial class App : Xamarin.Forms.Application
{
    public App()
    {
        Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
        InitializeComponent();
        MainPage = new NavigationPage(new MainPage());
    }
}
0
votes

If you want to make the toolbar's position static in Android, try adding this in [Activity] attribute in your MainActivity:

WindowSoftInputMode = Android.Views.SoftInput.AdjustNothing

More info here.