How to Use GIF file in Android Studio

Hi Friends, In this article, we are going to learn how to use GIF files in Android Studio step by step.

So lets, start the Android Studio and create a new project with empty Activity and start the Use GIF file in Android Studio.

How to add GIF in Android Project?

Step 1.

After creating a new project just open build.gradle(:app) file and add below line in dependencies.

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

Then click on “sync now” to to sync your gradle.

Step 2.

Past your GIF file inside the drawable directory and use it in step 3.

Step 3.

Open your .xml file and past below code inside this .xml

<pl.droidsonroids.gif.GifImageView
android:id="@+id/gifImageView"
android:layout_width="428dp"
android:layout_height="224dp"
android:layout_marginTop="232dp"
android:src="@drawable/indian1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.563"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Now Run your Application, it will work perfectly.

Thanks for visiting on our website 🙂

Connect with me on:

Instagram: https://www.instagram.com/shripaldba
Linkedin: 
https://www.linkedin.com/in/shripal-singh
Twitter: 
https://twitter.com/ocptechnology
Facebook: 
https://www.facebook.com/ocptechnology
YouTube:
 https://www.youtube.com/ocptechnology

Share this
Share
Share