adplus-dvertising
 
Android Learning

How to Play or View Gif Image in Android App

Yes, you can play or view gif animated gif images in your android studio app easily using an android library.

First of all, Create A New Android Studio Project, then add the below dependencies to the project-level build.gradle file as shown in the below screenshot:

mavenCentral()
Add mavenCentral()

Add the below dependencies in your app-level build.gradle as shown in the below screenshot:

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

Then add the below code to your activity_main.xml as shown in the below screenshot:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <pl.droidsonroids.gif.GifImageView
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/hiandroid" />
    <pl.droidsonroids.gif.GifImageView
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:src="@drawable/hellow" />
</LinearLayout>

Now everything is done, its time to run your android app and check it now, it should work like a pro. For more Information Watch the below video.

Click Below link To Download Source Code

Download

Leave a Comment