[英]How to display image using xamarin in android project
I trying to display a images in android project using xamarin.我尝试使用 xamarin 在 android 项目中显示图像。
I put folder Images
in my android project in directory Resources/drawable/Images
我将文件夹
Images
放在我的 android 项目的Resources/drawable/Images
目录中
I set on every image property AndroidResource
from BuildAction
(I'm not sure if that should be the case)我从
BuildAction
设置了每个图像属性AndroidResource
(我不确定是否应该是这种情况)
In the c# code I try to call the image with this code but not worked for me:在 c# 代码中,我尝试使用此代码调用图像,但对我不起作用:
if (descriptionForecast1 == "clear sky") { ImageDescriptionForecast1.Source = "Images/ClearSky.jpg"; ImageForecast1.Source = "Images/ClearSky.jpg"; }
Can I get an example of how to call the Images, because I get an error like this that the path is wrong:我可以获得一个如何调用图像的示例,因为我收到这样的错误,即路径错误:
/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 - Place images in the Resources/drawable directory with Build Action: AndroidResource.
Android - 使用 Build Action: AndroidResource 将图像放置在 Resources/drawable 目录中。 High- and low-DPI versions of an image can also be supplied (in appropriately named Resources subdirectories such as drawable-ldpi, drawable-hdpi, and drawable-xhdpi).
还可以提供图像的高和低 DPI 版本(在适当命名的资源子目录中,例如 drawable-ldpi、drawable-hdpi 和 drawable-xhdpi)。
do not create your own sub-folders in Resources不要在资源中创建自己的子文件夹
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.