diff --git a/Splat/Android/Bitmaps.cs b/Splat/Android/Bitmaps.cs index 3fa7073..93a06de 100644 --- a/Splat/Android/Bitmaps.cs +++ b/Splat/Android/Bitmaps.cs @@ -9,6 +9,8 @@ using Android.Graphics.Drawables; using System.Collections.Generic; using System.Linq; +using Path = System.IO.Path; + namespace Splat { public class PlatformBitmapLoader : IBitmapLoader @@ -55,6 +57,13 @@ namespace Splat return Task.Run(() => (IBitmap)new DrawableBitmap(res.GetDrawable(drawableList[source]))); } + // NB: On iOS, you have to pass the extension, but on Android it's + // stripped - try stripping the extension to see if there's a Drawable. + var key = Path.GetFileNameWithoutExtension(source); + if (drawableList.ContainsKey(key)) { + return Task.Run(() => (IBitmap)new DrawableBitmap(res.GetDrawable(drawableList[key]))); + } + throw new ArgumentException("Either pass in an integer ID cast to a string, or the name of a drawable resource"); }