-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Images don't load in Xamarin.Forms 4 when using Visual=Material #19
Comments
I'm trying to produce a minimal case for this but I can't... (these bugs are killing me! 🤬🤬🤬) |
Got it! Please find a repro at https://github.com/mikescandy/glidex/tree/wrapbug . I forgot that to trigger the issue I had to:
|
So I started a branch here to try all the new stuff: https://github.com/jonathanpeppers/glidex/compare/xf-4.0-pre Main thing I saw was I'll look at what might be happening when |
I think I saw an issue on xamarin.android that could be related to the binding project not compilinig, I'll see if I can link it here. |
If the binding project had: <PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0-preview9" /> Then you have to use |
no, I think support 28 can multitarget https://blog.xamarin.com/multi-targeting-with-android-support-library-v28/ |
It is working for me, could it be that you have The other thing is I'm using a master build of Xamarin.Android + VS 2019: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-builds-master/656/PublishUrls/ |
I think the issue is fixed in master. I'll see if I can try that tomorrow too. |
The only thing I remember is this: dotnet/android#2424 I think you would get a build error on incremental builds, though. |
Oh sorry @mikescandy I didn't read!
If that's the issue, yeah I fixed it in xamarin-android/master. Here is a workaround: 861719f I think we can close this, unless you are seeing this in the Android device log: glidex/glidex.forms/GlideExtensions.cs Lines 28 to 30 in 4c32d3b
|
I do see
|
Ok I searched XF for <Frame>
<Image WidthRequest="80" HeightRequest="80" Source="trump.png" />
</Frame>
|
That's how I triggered it in https://github.com/mikescandy/glidex/tree/wrapbug |
Fixes: #19 Context: https://github.com/xamarin/Xamarin.Forms/blob/94e6621f72cf3b19585253427aae4b70ba66af55/Xamarin.Forms.Platform.Android/Material/MaterialFrameRenderer.cs#L41 The problem surfaces when: - Using Xamarin.Forms 4.x preview - Enable `Visual="Material"` on the current page - Use an `<Image/>` inside a `<Frame/>` Since a `ContextThemeWrapper` is the `Context` of the `ImageView`, it was hitting this `else`: else { Forms.Warn ("Context `{0}` is not an Android.App.Activity, aborting image load for `{1}`.", imageView.Context, source); } I reworked this code so it also checks in `Forms.Context` to find the `Activity` instance.
Fixes: #19 Context: https://github.com/xamarin/Xamarin.Forms/blob/94e6621f72cf3b19585253427aae4b70ba66af55/Xamarin.Forms.Platform.Android/Material/MaterialFrameRenderer.cs#L41 The problem surfaces when: - Using Xamarin.Forms 4.x preview - Enable `Visual="Material"` on the current page - Use an `<Image/>` inside a `<Frame/>` Since a `ContextThemeWrapper` is the `Context` of the `ImageView`, it was hitting this `else`: else { Forms.Warn ("Context `{0}` is not an Android.App.Activity, aborting image load for `{1}`.", imageView.Context, source); } I reworked this code so it also checks in `Forms.Context` to find the `Activity` instance.
Fixes: #19 Context: https://github.com/xamarin/Xamarin.Forms/blob/94e6621f72cf3b19585253427aae4b70ba66af55/Xamarin.Forms.Platform.Android/Material/MaterialFrameRenderer.cs#L41 The problem surfaces when: - Using Xamarin.Forms 4.x preview - Enable `Visual="Material"` on the current page - Use an `<Image/>` inside a `<Frame/>` Since a `ContextThemeWrapper` is the `Context` of the `ImageView`, it was hitting this `else`: else { Forms.Warn ("Context `{0}` is not an Android.App.Activity, aborting image load for `{1}`.", imageView.Context, source); } I reworked this code so it also checks in `Forms.Context` to find the `Activity` instance.
As described in xamarin/Xamarin.Forms#4674, when using XF4 and setting the ContentPage Visual to Material, images don't load.
The visual code uses ContextThemeWrapper to apply Material themes to controls, but in GlideExtensions.cs:
Without the else images are loaded correctly.
The text was updated successfully, but these errors were encountered: