In this video it shows the steps to implement the animated gif images in your Android App.
GIF, Graphics Interchange Format, are short animated images. In this tutorial it uses ‘pl.droidsonroids.gif:android-gif-drawable:1.2.25’ dependency in gradle file. Maven repository for this dependency can be referred at: https://search.maven.org/artifact/pl.droidsonroids.gif/android-gif-drawable/1.2.25/aar
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Complete source code and other details:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<pl.droidsonroids.gif.GifImageView
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_marginStart="64dp"
android:layout_marginTop="120dp"
android:src="@drawable/bird"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
plugins {
id 'com.android.application'
}
android {
namespace 'com.programmerworld.gifimageapp'
compileSdk 32
defaultConfig {
applicationId "com.programmerworld.gifimageapp"
minSdk 32
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'
}
Java code is not relevant here.
GIF Image used in this example:
Snapshots from Android Studio: