Redth / ResizetizerNT

Add SVG's and PNG's to your shared Xamarin Project
MIT License
318 stars 31 forks source link

Use SharedImages as map marker icons on Android #16

Closed TouchBoarder closed 4 years ago

TouchBoarder commented 4 years ago

'Resource.Drawable' does not contain a definition for 'map_marker_icon'

To make this work for Android I had to include a version of the image with the same name as the SharedImage (SVG in the netstandard2.0 project) in the Android project (PNG). I think you can use any drawable-dpi folder for this, but I used the drawable-ldpi folder to add the smallest version of the image, as the other drawable-dpi images will be generated by ResizetizerNT, this ensures the Resources definition is generated and the image can be used native like a map marker icon etc.

The drawable folder without dpi suffix can also be used, Android will select the images from the drawable-*dpi folder that matches the dpi of the screen. So the image added for generating a Resources definition can be as small as possibly as it will not be used or will be replaced by ResizetizerNT.

Redth commented 4 years ago

Something else must be going on here as you should not need to include anything, it's done for you.

What version of Visual Studio 2019 are you using?

TouchBoarder commented 4 years ago

16.6.2 at the time, just updated to 16.6.3. This was to make it work in a custom Android map renderer with BitmapDescriptorFactory.FromResource(Resource.Drawable.map_marker_icon);, not shared code.

Redth commented 4 years ago

Oh. Ya. This library doesn’t provide any actual code implementation for your app to use shared images at runtime. Use Xamarin.Forms for that. I have no plans to add anything for this.

themronion commented 3 years ago

@TouchBoarder i solved a similar issue by just adding the needed single png to the drawable folder, building, and then deleting it from the drawable folder. That way after the build the plugin generates all the needed png somewhere and u can reference them as u normally would. The only problem with this approach is that if u want to clean and rebuild you might need to repeat this procedure.