Xamarin 中的 LayoutInDisplayCutoutMode 问题
Problem with LayoutInDisplayCutoutMode in Xamarin
我在 Xamarin.Android 中设置剪切模式的属性时遇到了一个奇怪的问题。我想在我的应用程序中添加对剪切模式的支持,因此我更新了项目以使用 SDK 9.0,并将这一行添加到我的 Activity:
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(馅饼)。
旧设备 API 通过“新” AndroidX
“Compat” 库支持剪切模式(androidx.core.view.DisplayCutoutCompat
),但 Microsoft/Xamarin 仍未发布public支持他们。
围绕此功能差距存在许多基于 github 的问题(对于新的 AndroidX 的 WorkManager 和其他我必须创建自己的绑定...)
现在您可以执行 API 级别检查,
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.P)
{
Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
}
In Android P we added APIs to let you manage how your app uses the display cutout area, as well as to check for the presence of cutouts and get their positions.
For devices running Android 8.1 (API 27), we've also back-ported the layoutInDisplayCutoutMode activity theme attribute so you can control the display of your content in the cutout area. Note that support on devices running Android 8.1 or lower is up to the device manufacturer, however.
To make it easier to manage your cutout implementation across API levels, we've also added DisplayCutoutCompat in the AndroidX library, which is now available through the SDK manager.
我在 Xamarin.Android 中设置剪切模式的属性时遇到了一个奇怪的问题。我想在我的应用程序中添加对剪切模式的支持,因此我更新了项目以使用 SDK 9.0,并将这一行添加到我的 Activity:
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(馅饼)。
旧设备 API 通过“新” AndroidX
“Compat” 库支持剪切模式(androidx.core.view.DisplayCutoutCompat
),但 Microsoft/Xamarin 仍未发布public支持他们。
围绕此功能差距存在许多基于 github 的问题(对于新的 AndroidX 的 WorkManager 和其他我必须创建自己的绑定...)
现在您可以执行 API 级别检查,
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.P)
{
Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
}
In Android P we added APIs to let you manage how your app uses the display cutout area, as well as to check for the presence of cutouts and get their positions.
For devices running Android 8.1 (API 27), we've also back-ported the layoutInDisplayCutoutMode activity theme attribute so you can control the display of your content in the cutout area. Note that support on devices running Android 8.1 or lower is up to the device manufacturer, however.
To make it easier to manage your cutout implementation across API levels, we've also added DisplayCutoutCompat in the AndroidX library, which is now available through the SDK manager.