How to play animated GIF in TextView? - android

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

Related

Adding Video in Placeholder

I want to use a video placeholder before the actual images loads up. I am using a Fullscreen ImageView to load the image but till the time image is loaded to the imageview, i want to show a placeholder video at that place. I am not sure, even if it is feasible or not. If in any case it is feasible, would be looking for the way to get out of this.
Finally got this working, i was able to use GIF animation as my Placeholder using Glide.
Loaded GIF file from drawable resource.
RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.drawable.placeholder);
Glide.with(context)
.setDefaultRequestOptions(requestOptions)
.load(articlesListChild.get(position).getArticleImage())
.thumbnail(Glide.with(context).load(R.drawable.logo_anim_full)) // This line did the magic
.into(imageContentIv);

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

Android: How to use TextView in placeholder of Glide or Picasso

i am using Glide or Picasso for loading the image like
Glide.with(context).load(POST_IMAGE).placeholder(R.drawable.loading_img).error(R.drawable.bg_480_800).into(image);
Picasso.with(context).load("image url").error(R.drawable.bg_480_800).placeholder(R.drawable.loading_img).into(holder.imageURL);
In these two, i'm using image as place holder from the drawable folder. Now i want to use text inside the place holder instead of image from drawable folder.
So, please help me to load text instead of loading image from the drawable folder
Placeholder is a Drawable, so what you'll need is some kind of Drawable that is able to display text. This library does exactly that, and does it pretty well.

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.

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