You are currently viewing How to Display Animated GIF in a Xamarin based Android Application?

How to Display Animated GIF in a Xamarin based Android Application?


How to Display Animated GIF in a Xamarin based Android Application?

Related: Display Animated GIF in a Xamarin based Android Application

Android doesn’t provide any support for GIF animation in the ImageView. This post gives you complete information about displaying GIF in a Xamarin based Android application.

Note: This example is based on Xamarin based Android Application using C# language. If you are looking for a native java based solution, I like to suggest StackOverflow post(

Please follow the following steps to display animated GIF in an Android application.

Step 1: Install “Refractored.GifImageView” Nuget package into your Xamarin based Android project.


Step 2: Add the following code into your Main Android Layout file (XML) or in the layout where you want to display GIF image.

    android:layout_height="match_parent" />

Step 3: Add GIF file to your Drawable folder ( here loading.gif)

Step 4: Update your Activity class.

Add using statement:

using Felipecsl.GifImageViewLibrary;

Find the GIFImageView and load animation

GifImageView myGIFImage;   
protected override void OnCreate(Bundle savedInstanceState)

    // Set our view from the "main" layout resource

    myGIFImage= FindViewById<GifImageView>(Resource.Id.myGIFImage);
    // From Drawable
                Stream input = Resources.OpenRawResource(Resource.Drawable.loading);
                // You should convert the "input" into Byte Array 
                byte[] bytes = ConvertByteArray(input);

private byte[] ConvertByteArray(Stream input)
                    byte[] buffer = new byte[16 * 1024];
                    using (MemoryStream ms = new MemoryStream())
                        int read;
                        while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
                            ms.Write(buffer, 0, read);
                        return ms.ToArray();

You can stop animation using the following code


and start again using 


That all done. You can also find more details about the same here (

Read more Xamarin related posts:

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

As you found this post useful...

Share this post on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?