Reputation: 985
I trying to display a images in android project using xamarin.
I put folder Images
in my android project in directory Resources/drawable/Images
I set on every image property AndroidResource
from BuildAction
(I'm not sure if that should be the case)
In the c# code I try to call the image with this code but not worked for me:
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)
Upvotes: 0
Views: 336
Reputation: 89102
from the docs
Android - Place images in the Resources/drawable directory with Build Action: AndroidResource. 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).
do not create your own sub-folders in Resources
Upvotes: 1