[英]Xamarin forms navigation bar scrolling on Android
I have a simple File->New Project Xamarin Forms app just created.我有一个简单的文件-> 新建项目 Xamarin Forms 应用程序刚刚创建。 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.
我在三星 Note 3 手机上观察到这种行为。 This doesn't happen in iOS.
这不会发生在 iOS 中。
https://github.com/JohnLivermore/SampleXamarinApp/tree/funkyNavbar https://github.com/JohnLivermore/SampleXamarinApp/tree/funkyNavbar
App.xaml App.xaml
public partial class App : Application
{
public App()
{
InitializeComponent();
var mainPage = new MainPage();
var nav = new NavigationPage(mainPage);
MainPage = nav;
}
}
MainPage.xaml主页.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>
Add the following code in App.cs to make page auto-resizable.在 App.cs 中添加以下代码以使页面自动调整大小。
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());
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.