Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Android AppCompat crash while setting TabIcon if Non-Drawable resource specified

$
0
0

Version:
Xamarin.Forms v2.1.0.6529

Setup: In a Tabbed Page, I have added couple of Navigation page with PageIcon specified as a full path.
iOS works flawlessly, as it's using UIImage to load from path.
On Droid, I believe it's trying to get the file using ResourceManager from drawable. This is where it is crashes.

Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout(bool changed, int l, int t, int r, int b)
Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout(bool changed, int l, int t, int r, int b)
Android.Views.ViewGroup.n_OnLayout_ZIIII(IntPtr jnienv, IntPtr native__this, bool changed, int l, int t, int r, int b)Android.Views.ViewGroup.cs:4044
at (wrapper dynamic-method) System.Object:46ac048c-9a7d-4878-adfe-21d3b3e46323 (intptr,intptr,bool,int,int,int,int)

If I set PageIcon to blank, or to a filename from drawable, it works fine.

Why?
I really dislike that I have to have resources in different places with different naming strategy - especially for droid, where I have to copy correct files to different folders. My idea is to have a compiled resources with all the sizes in one place. Then I would extract the correct size resources to temporary folder and use it from there.
Some of the controls allow me to have an ImageSource, where I can pass StreamImageSource; but unfortunately Tab, Buttons and ToolbarIcon only supports a FileImageSource.

My idea for local patch (until perhaps Xamarin Forms checks for resource existence first) - using a CustomTabRenderer, perhaps I can keep a local dictionary variables of all the pages icons within tab children and set it to null; which would skip the method in base that's causing the crash; finally I draw the icon myself from local dictionary. Hopefully that would work.


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>