How to load GIF file from gallery. As it can be lay from accessing the drawable or using the web url. But how to access it from gallery. not like the path i.e. file//folder1//images// file.gif istead i need to load it via onclick> open gallery(show all files i.e. images, gif etc)> choose one gif and then it open into my app(GifImageView)
Asked
Active
Viewed 1,038 times
0
-
Possible duplicate of [How to pick an image from gallery (SD Card) for my app?](http://stackoverflow.com/questions/2507898/how-to-pick-an-image-from-gallery-sd-card-for-my-app) – Frederic Klein Oct 16 '16 at 19:46
1 Answers
1
In your build.gradle file: Compile this dependency.
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);

Faraz Tariq
- 54
- 7