Monday 12 November 2018

Xamarin image assets

When adding image assets to your xamarin forms app, they have to be located in your various device specific projects with various sizes that your hardware decides which to use.

for IOS you place all of your images in the resource folder using the following naming convention with a build action of BundleResouce
Path Naming convention Ratio size
/Resources myfile.png 1 25px^2
/Resources myfile@2x.png 2 50px^2
/Resources myfile@3x.png 3 75px^2

whereas for Droid it would look like with a build action of AndriodResource
Path Naming convention Ratio size
/Resources/drawable-hdpi/ myfile.png 3 75px^2
/Resources/drawable-xhdpi/ myfile.png 4 100px^2
/Resources/drawable-xxhdpi/ myfile.png 6 150px^2
/Resources/drawable-xxxhdpi/ myfile.png 8 200px^2

and finally for UWP they are as follows with an build action of Content
Path Naming convention Ratio size
/Assets myfile-100.png 1 25px^2
/Assets myfile-200.png 2 50px^2
/Assets myfile-400.png 4 100px^2