Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Xamarin Forms - WebView Html Source issue

Emixam23Emixam23 USMember ✭✭✭

I'm coming today because I'm stuck on the load of a GIF with the android platform. I know it works because it works for UWP and iOS, however android doesn't work..

I have this object:

public class Gif : WebView
    public string GifSource
            var html = new HtmlWebViewSource();
            html.Html = String.Format(@"<html><body style='background: #FF0000;'><img src='{0}' style='width:100%;height:100%;'/></body></html>", "");
            Debug.WriteLine("Html.Source = '{0}'", html.Html);
            this.Margin = -10;
            this.Source = html;
        get { return (string)GetValue(SourceProperty); }

So I just declare this Gif in my xaml side:

<AbsoluteLayout AbsoluteLayout.LayoutBounds="0.5, 0.5, 1, 1" AbsoluteLayout.LayoutFlags="All">
                AbsoluteLayout.LayoutBounds="0.5, 0, 1, 0.9"
                GifSource="Gifs/LoginBackground.gif" />
                AbsoluteLayout.LayoutBounds="0.5, 0.5, 1, 1"
                BackgroundColor="Transparent" />

PS: I declare a BoxView to escape the possibilty of moving the webview by a user gesture.

Now the thing is, it works on UWP perfectly, with the both code :

html.Html = String.Format(@"<html><body style='background: #FF0000;'><img src='{0}' style='width:100%;height:100%;'/></body></html>", "");
this.Source = html;


this.Source = "";

On Android, the this.Source = ""; works, however the first solution doesn't work, which is a problem. By create my own html it allows me to make the gif fill my view unlike the link... On more point, if I delete the style='width:100%;height:100%;' of the html, it works, but one more time, not with the good size..

Any idea? Thank in advance !

Sign In or Register to comment.