Problem with Animated gif on Android - android

I need some advice about animation. I have an animated GIF, but how to put in Android app to be animation. When I put it doesn't move at all. I read something about animation in Android and I need to have pictures for animation. Is there any solution for this ?

Android does not support animated GIFs much. You can use an AnimationDrawable, perhaps defined from frames using a drawable XML file.

you can do it by using GIF image in your app as Splash screen.
Android does not support animated GIFs. so extract gif to png pictures with gif2png and it works with XML.
And Other Option Adding gif image in an ImageView in android
Adding gif image in an ImageView in android

100 % Work...
1) Add Glide library dependency...
compile 'com.github.bumptech.glide:glide:4.2.0'
2)
imageView = findViewById(R.id.gifImage);
3)
Glide.with(getApplicationContext())
.asGif()
.load(R.drawable.gifImage)
.into(imageView);
just use .asGif() before .load()

Related

Xamarin android Glide webp animation

I'm using this library (Xamarin binding library of Glide), to display Gif in my app. But i would like to display Webp animations to save some space in my app.
Glide.With(context)
.Load(url)
.Into(imageView);
But the animation is locked on the first frame and didn't played (webp animation example).
Did i miss something?
Thank you.
Regards, Samih
It's a known issue.
Right now, Glide has no built-in webp support and defaults to the system.It seems like Glide will work when you introduce some libraries that support WebP.

Show GIF image full screen using Fresco library

I'm using Fresco library to show images full screen. How to show animated GIF images full screen using that library? Is there any other optimal solution?
You have to add the dependency for Animated GIF decoding to your Gradle file:
implementation 'com.facebook.fresco:animated-gif:1.12.1'
Then, simply load the image into a SimpleDraweeView:
mSimpleDraweeView.setController(Fresco.newDraweeControllerBuilder()
.setAutoPlayAnimations(true)
.setOldController(simpleDraweeView.getController())
.setUri(yourGifUrl)
.build());

How to display gif in AppIntro library?

I am using the AppIntro https://github.com/apl-devs/AppIntro
library with the default slides builder.
It works great but I am having trouble passing gifs as the drawable for the default builder.
addSlide(AppIntroFragment.newInstance(title, description, image, backgroundColor));
I read that android has issues displaying gif by default and I have to use GifImageLoader or Glide to load the gif.
Glide
.with(context)
.load("imageUrl")
.asGif()
.placeholder(R.drawable.gifImage)
.crossFade()
.into(imageView)
I could try this but I don't have an imageView where I can pass into the argument if I use the default builder.
I also tried GifDrawable gifFromResource = new GifDrawable( getResources(), R.drawable.anim ); from Display Animated GIF but it gives an error.
My next closest option is to create a custom fragment to use with AppIntro and I really don't want to do that.
Is there any way to pass the gif into the default slide builder and have it play?
You can use Simple Target from Glide library. Override onResourceReady() and load this as image in new slide. Please note I have not tried this with gif and have not access to my dev machine now.
Simple Target docs

Glide Load Image Not Complte

A loading Gif And I use Glide to load Gif, And the third bar show to me is not complete, It show white area in third bar which is not be shown.(English is poor, sorry), like thisError Showing Dear all, How can I solve it?
ScaleType="fitXY"
Glide.with(context).load(R.drawable.loading).into(imageView);
1:
use GifImageView
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/src_anim"
android:background="#drawable/bg_anim"
/>
Android-Gif-Drawable
Steps to load Gif images from drawable
You need to move your loading Gif image tores/raw folder of your project
(
if your project don't have raw folder in resource directly then simply make one and put your gif in it )
and then you can simply load your gif with just one line of code
Glide.with(this)
.load(R.raw.loading)
.into(new GlideDrawableImageViewTarget(
(ImageView) findViewById(R.id.image)));
Edits:-
White area in Gif image could be becaouse of streatching gif this is how it look like in my device
Alternatively you can look into this open source library for loading animation
https://github.com/81813780/AVLoadingIndicatorView

Replace ImageView from PNG to GIF

I want to replace ImageView from PNG to GIF. I tried with this code:
ImageView kotek = (ImageView)findViewById(R.id.imageView4);
nYAn.setImageResource(R.drawable.kot);
But GIF isn't animate.
What i should do?
Sorry for my bad English :P
ImageView does not support animated GIFs. Either convert the animated GIF into an AnimationDrawable, or use a third-party library for displaying the animated GIFs.

Categories

Resources