因为不同平台弹出效果不一样,Xamarin只有简单的弹出样式
官方地址:https://docs.microsoft.com/zh-cn/xamarin/xamarin-forms/user-interface/pop-ups
当我们需要加载框的时候发现这完全不够用
所以,我用了Acr.UserDialogs包
参考链接:https://www.nuget.org/packages/Acr.UserDialogs/
不过在.Droid中需要适配一下,不然会报一下错误
In android, you must call UserDialogs.Init(Activity) from your first activity OR UserDialogs.Init(App) from your custom application OR provide a factory function to get the current top activity via UserDialogs.Init(() => supply top activity)
方法:
在MainActivity.cs中加一句UserDialogs.Init(this);
protected override void OnCreate(Bundle savedInstanceState)
{
UserDialogs.Init(this);
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
参考:https://stackoverflow.com/questions/40218229/using-userdialogs-in-android