I have a Xamarin Forms Android app and when I'm using the following code
var image = new Image { Source = "lock.png" };
to show an image, but the image isn't showing though.
And then I try to change the source to Icon.png (the default Xamarin icon) and it working fine.
Does anybody know how to make this image show in my app?
(ps: image path : ".\MyApp.Droid\Resources\drawable\lock.png".)
I also faced to this issue. I tried above mentioned two solutions too. But didn't. People can try below suggestions one by one,
I didn't build the project, after adding the image. It was my problem. May someone get benefited from my answer.
Make sure that image has Build Action set to "Android Resource". Otherwise, it is not copied to final package properly and there is no image for app to show. This is described in guide here: https://developer.xamarin.com/guides/xamarin-forms/working-with/images/#Local_Images
Another problem could be that the image is too large to be rendered. If everything else fails, try creating a smaller version of the image.
I hope this helps somebody.
For others who may come here, also check to make sure your image doesn't have dashes/hyphens in the file name as per https://stackoverflow.com/a/35760195/908677 - that was why my image wasn't showing up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With