Replace ImageView from PNG to GIF - android

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.

Related

How to animate webp image in android

I have used one webp image url in my app via glide and set it to image view but the image which is an animated one is not getting animated. Image is showing up but not getting animated.
You can use this library to animate webp file:
GlideWebpDecoder

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

Display a gif image in Custom listview android?

I want to display a gif image http://peacechild.org/wp-content/uploads/2012/09/loading.gif
in each element of custom listview.
How to do that?
I know that we have to make use of the movie class but how to use it?
An example would be helpfull.
Thanks
Use this Animated GIF app sample
OR
Use a webview to load it
Use VideoView.
Natively ImageView does not support animated image. You have two options to show animated gif file
1.Use VideoView
2.Use ImageView and Split the gif file into several parts and then apply animation to it

How to play animated GIF in TextView?

I'm using TextView for displayng text with GIF images:
Html.ImageGetter imageGetter=new Html.ImageGetter imageGetter() {
public Drawable getDrawable(String source) {
return getDrawableFromSd(String source);
}
}
mtTextView.setText(Html.fromHtml(text,imageGetter,null));
Some files are animated, but it doesn't animate when displaying in TextView. How to display it with animation?
How to play animated GIF in TextView?
You don't. Android has little support for animated GIFs, and definitely not via an ImageSpan in a TextView.
But how to display text with animated smiles in ListView's item another way?
Most likely, you don't.
You are welcome to try an AnimationDrawable when you create your ImageSpan. Or, you are welcome to try something like a LevelListDrawable, where you "animate" it yourself by switching between levels on a periodic basis.
You can use Glide to display gif rather than using WebView. its as simple as
Glide.with(context)
.load(gifImageUrl)
.asGif()
.placeholder(R.drawable.loading)
.crossFade()
.into(imageView);
You may also like to read this post :- http://inthecheesefactory.com/blog/get-to-know-glide-recommended-by-google/en

Problem with Animated gif on 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()

Categories

Resources