我正在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());
}
答案 0 :(得分:3)
您需要将文件“nextera.png”添加到Android项目中
Resources/drawable
Build Action的目录:AndroidResource
在Xamarin中添加图片的完整指南 - Xamarin official guideline for loading a local image