Reputation: 4044
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?
Upvotes: 9
Views: 4477
Reputation: 45090
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
Upvotes: 8
Reputation: 1006944
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.
Upvotes: 10