Xamarin.Forms 中针对平台的 UI 调整
Platform specific UI adjustments in Xamarin.Forms
我有一个 Xamarin.Forms 屏幕定义是核心库如下:
Content = new WebView
{
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Source = "https://google.com",
};
作为 iOS 的结果,内容与系统托盘重叠(带有系统图标的顶部栏)。您可以在左上角看到它们。问题是相同的托盘与 Android 的 webview 分开,我不能只添加静态上边距。我需要在 "per platform" 的基础上进行。有办法实现吗?
这是可能的。您可以使用 Device.OnPlatform()
方法。在 the API docs.
中了解更多信息
用法可以是:
Device.OnPlatform (iOS: () => webView.Padding = new Thickness (0, 20, 0, 0));
20
是状态栏的高度。
还有一些关于 platform tweaks here 的文档。
我有一个 Xamarin.Forms 屏幕定义是核心库如下:
Content = new WebView
{
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Source = "https://google.com",
};
作为 iOS 的结果,内容与系统托盘重叠(带有系统图标的顶部栏)。您可以在左上角看到它们。问题是相同的托盘与 Android 的 webview 分开,我不能只添加静态上边距。我需要在 "per platform" 的基础上进行。有办法实现吗?
这是可能的。您可以使用 Device.OnPlatform()
方法。在 the API docs.
用法可以是:
Device.OnPlatform (iOS: () => webView.Padding = new Thickness (0, 20, 0, 0));
20
是状态栏的高度。
还有一些关于 platform tweaks here 的文档。