Greg
Greg

Reputation: 599

Xamarin Android - Gif in WebView is displayed blank

I got an issue while trying to display a gif for my UI.

When the app is launched, the .gif file is correctly loaded (if i change the path, a loading error occure) but the webView is displayed blank.

Android version : marshmallow 6.0 API lvl 23

the "ship_sea.gif" is currently located in Assets Folder, with "Android Asset" in build action.

the axml:

 <WebView
            android:id="@+id/myWebGIF"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:layout_marginTop="50dp"
            android:layout_marginLeft="50dp" />

the .cs :

WebView webGif = FindViewById<WebView>(Resource.Id.myWebGIF);
webGif.LoadUrl(string.Format("file:///android_asset/ship_sea.gif"));

Why is this not working? It is really simple and I can't figure out what is the problem. Could it be the device as this post suggests (NVIDIA Shield Tablet K1)?

Upvotes: 0

Views: 574

Answers (1)

Greg
Greg

Reputation: 599

Ok guys, here is the answer :

Be sure that your canvas is the same size as your gif.

In my case, i had a particular large gif, and the only part rendered in my canvas was the top-left (a blank part).

The default background color for a webView is white, so it resulted in a blank view.

Problem solved : there was no error, just wrong interpretation of the problem.

Upvotes: 1

Related Questions