我正在Xamarin共享应用程序中创建欢迎屏幕。欢迎屏幕必须显示图像几秒钟,然后导航到登录页面。它在IOS中完美运行,但在Android中不显示图像。
public Page()
{
//var beachImage = new Image { Aspect = Aspect.AspectFit };
//beachImage.Source = ImageSource.FromFile("nextera.png");
Image logo = new Image { WidthRequest = 800, HeightRequest = 800 };
logo.Source = ImageSource.FromFile("nextera.png");
logo.Aspect = Aspect.AspectFit;
Content = new StackLayout
{
Children = { logo },
Padding = new Thickness(0, 20, 0, 0),
VerticalOptions = LayoutOptions.StartAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand
};
WaitAndExecute(2000);
}
private async Task WaitAndExecute(int milisec)
{
await Task.Delay(milisec);
await Navigation.PushAsync(new Login());
}
您需要将“ nextera.png”文件添加到android项目中
Resources/drawable
Build Action目录:AndroidResource
在Xamarin中添加图像的完整指南 -Xamarin加载本地图像的官方指南
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句