Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display .gif file in imageview?

My layout have lots of imageviews. I want to show .gif animated file in just one imageview. I tried Yash method (Adding gif image in an ImageView in android) but .gif file shown all layout. Other views dissappeared.

I want to show all.

Any idea?

like image 762
Breed Hansen Avatar asked May 10 '13 09:05

Breed Hansen


People also ask

Can we show GIF in ImageView in Android?

Here we are loading the gif using ImageView and Glide Library. Insert the following dependency to build. gradle file of your project. Navigate to the app > res > layout > activity_main.

Can I use GIF as splash screen?

Android: Sure, add your individual splash screen graphics. Just replace the included splash. gif files with your own image file. Make sure to use GIF format (animated or static).

Can we add GIF in Android Studio?

This example demonstrates how do I display animated gif images in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.


1 Answers

If you don't want to use Glide, just add this to your dependencies and create your unique 'gif'. Check for the latest version before use. ImageView:

implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'

Works very efficiently with minimal lines of code. An example is:

<pl.droidsonroids.gif.GifImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/dancer"
        android:src="@drawable/maddancer" />
like image 145
Taslim Oseni Avatar answered Sep 27 '22 21:09

Taslim Oseni