当键盘打开 Xamarin 窗体时,工具栏将上升



我想在显示软键盘时保持工具栏在顶部可见。我尝试了WindowsSoftInputMode的所有选项,但没有一个有效。在将 xamarin 表单升级到 2.3.4.247 后,这已经开始发生。它以前工作正常。

在 xamarin 表单更新之前 上一个结果

在 xamarin 表单更新结果之后

MainActivity 中的以下代码解决了我的问题。

参考: https://gist.github.com/jimmgarrido/e36033b26f01e8da091fd321d41d991a

protected override void OnCreate(Bundle bundle)
{
ToolbarResource = Resource.Layout.toolbar;
base.OnCreate(bundle);
//Remove the status bar underlay in API 21+
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
Window.DecorView.SystemUiVisibility = 0;
var statusBarHeightInfo = typeof(FormsAppCompatActivity).GetField("_statusBarHeight", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
statusBarHeightInfo.SetValue(this, 0);
Window.SetStatusBarColor(new Android.Graphics.Color(18, 52, 86, 255));
}

global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
App.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
}

最新更新