Android ImageView that handles animated GIF images
GifImageView
Android ImageView that handles Animated GIF images
Usage
In your build.gradle
file:
dependencies {
compile 'com.felipecsl:gifimageview:2.1.0'
}
In your Activity class:
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gifView = (GifImageView) findViewById(R.id.gifImageView);
gifView.setBytes(bitmapData);
}
@Override
protected void onStart() {
super.onStart();
gifView.startAnimation();
}
@Override
protected void onStop() {
super.onStop();
gifView.stopAnimation();
}
If you need to post-process the GIF frames, you can do that via GifImageView.setOnFrameAvailable()
.
You can see an example of that in the sample app included on the repository.
gifImageView.setOnFrameAvailable(new GifImageView.OnFrameAvailable() {
@Override
public Bitmap onFrameAvailable(Bitmap bitmap) {
return blurFilter.blur(bitmap);
}
});
You can also reset an animation to play again from the beginning gifImageView.resetAnimation();
or show a specific frame of the animation gifImageView.gotoFrame(3)
;