GifImageView is light weight and efficient library to display Gif images in android application.
GifImageView is compatible with API LEVEL 21 or above.
- Use jitpack in your build.gradle file to install GifImageView.
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.haseebazeem15:gifImageView:1.4'
}
Create this GifImageView element in your layout xml file:
<com.haseebazeem.sampleGif.GifImageView
android:id="@+id/gifImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:src="@drawable/your_gif_file"
/>
Inflate GIF Drawable programmatically using:
GifImageView gifImageView;
gifImageView = (GifImageView) findViewById(R.id.gifImage);
gifImageView.setGifImageResource(R.drawable.splashscreen);
Inflate GIF Uri using:
GifImageView gifImageView;
gifImageView = (GifImageView) findViewById(R.id.gifImage);
Uri uri = URI_OF_YOUR_GIF_FILE
gifImageView.setGifImageUri(uri);
Inflate GIF using File object & Path:
GifImageView gifImageView;
gifImageView = (GifImageView) findViewById(R.id.gifImage);
File file = new File("path/to/gif_file");
gifImageView.setGifImageFile(file);
String path = "path/to/gif_file";
gifImageView.setGifImageFile(path);
Make sure to import gif file in all drawable directories like drawable-v24, drawable etc.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.