繁体   English   中英

如何在 android 项目中使用 xamarin 显示图像

[英]How to display image using xamarin in android project

我尝试使用 xamarin 在 android 项目中显示图像。

  1. 我将文件夹Images放在我的 android 项目的Resources/drawable/Images目录中

  2. 我从BuildAction设置了每个图像属性AndroidResource (我不确定是否应该是这种情况)

  3. 在 c# 代码中,我尝试使用此代码调用图像,但对我不起作用:

     if (descriptionForecast1 == "clear sky") { ImageDescriptionForecast1.Source = "Images/ClearSky.jpg"; ImageForecast1.Source = "Images/ClearSky.jpg"; }

我可以获得一个如何调用图像的示例,因为我收到这样的错误,即路径错误:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Aapt2.targets(3,3): Error APT2144: invalid file path '/Users/pizhev/Projects/WeatherLocationInfo 0.0.1/WeatherLocationInfo.Android/obj/Debug/res/drawable/images/lightrain1.jpg'. (APT2144) (WeatherLocationInfo.Android)

文档

Android - 使用 Build Action: AndroidResource 将图像放置在 Resources/drawable 目录中。 还可以提供图像的高和低 DPI 版本(在适当命名的资源子目录中,例如 drawable-ldpi、drawable-hdpi 和 drawable-xhdpi)。

不要在资源中创建自己的子文件夹

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM