Android Xamarin中LayoutInDisplayCutoutMode存在问题
在Xamarin.Android中设置剪切模式的属性有一个奇怪的问题。我想在我的应用程序中添加对剪切模式的支持,因此我更新了项目以使用SDK 9.0,并在我的活动中添加了这一行:Android Xamarin中LayoutInDisplayCutoutMode存在问题,android,xamarin,xamarin.android,android-9.0-pie,Android,Xamarin,Xamarin.android,Android 9.0 Pie,在Xamarin.Android中设置剪切模式的属性有一个奇怪的问题。我想在我的应用程序中添加对剪切模式的支持,因此我更新了项目以使用SDK 9.0,并在我的活动中添加了这一行: Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges; 我的项目可以编译,但当它运行时,我会在上面的一行中出现此异常: Java.Lang.NoSuchFieldError: no "I" field "l
Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
我的项目可以编译,但当它运行时,我会在上面的一行中出现此异常:
Java.Lang.NoSuchFieldError: no "I" field "layoutInDisplayCutoutMode" in class "Landroid/view/WindowManager$LayoutParams;" or its superclasses
我的项目设置是:
Compile using Android version: Android 9.0 (Pie)
Minimum Android version: Android 4.3 (API Level 18)
Target Android version: Android 9.0 (API Level 28)
所有nuget库都是最新的。
LayoutInDisplayCutoutMode
已添加到API级别28(Pie)中
对于剪切模式(AndroidX.core.view.DisplayCutoutCompat
),通过“新的”AndroidX
“Compat”库提供了对旧设备API的支持,但Microsoft/Xamarin尚未发布对它们的公共支持
围绕这一特性缺口,有许多基于github的问题(比如新AndroidX的WorkManager和其他我必须创建自己的绑定…)
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.P)
{
Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
}