Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Forms image not showing

I have a Xamarin Forms (2.0) Android app where I'm trying to show an image. I've got an icon called icon-pages-r1.png which I'm trying to show using the following code:

<Image Source="icon-pages-r1.png" />

The image isn't showing though. When I change the source to Icon.png (the default Xamarin icon) it does work.

The image is a semi-transparent PNG (thus a colored icon in the middle and transparent around it), it's 46x46 and in Windows it shows fine as item type PNG File. I tried opening the image in Paint and re-saving it (which kills the transparency) but that doesn't work either. The Build Action for the images are AndroidResource with Copy to Output Directory set to Do not copy.

Does anyone know why I can't get this image to show in my app?

like image 853
Leon Cullens Avatar asked Mar 02 '16 18:03

Leon Cullens


1 Answers

When binding to the name of an image resource in android I found it must be:

  • in Resources/Drawable folder
  • set Build Action: AndroidResource
  • set Copy to Output: Do not copy
  • doesn't allow hyphens in name
  • name is case sensitive
like image 132
Mike Benkovich Avatar answered Sep 30 '22 15:09

Mike Benkovich