Load GIF Resource Graph into Android ImageView based on open source framework Glide

Source: Internet
Author: User

"Third-party open source framework Android Glide loading GIF resource images to Android ImageView"

Normally Android ImageView can't load GIF images, and if you don't do any processing, the GIF loaded into ImageView shows only the first frame. There are many solutions available on the web, and there are many open source frameworks that customize the GIF view to load GIFs, mostly with the help of Android movie, the GIF image resource as a stream, parsing into Android movie display, The basic idea of these customizations is to first detect if the image resource is a GIF, and if so, parse it according to Android movie.
There is an Android glide open source framework that itself does a good job of loading and caching pictures, and I have previously written an article specifically on how to use the Android Glide library in your own project specifically (the link address of the article: http://blog.csdn.net/ zhangphil/article/details/45535693), at the same time, Android glide loading GIF pictures is also very convenient, the need to load the GIF map into the drawable directory, and then the normal andriod ImageView setting a picture resource r.drawanle.xxx exactly the same, very simple. or from the Web URL to load a picture, the developer does not care whether the picture resource is GIF or other JPG or PNG format, directly as a normal picture loading can, as to the image of the resource format of the judgment processing and drawing, there are Android glide all do.


Now for example:

Package Zhangphil.gif;import Com.bumptech.glide.glide;import Android.support.v7.app.actionbaractivity;import Android.widget.imageview;import Android.os.bundle;public class Mainactivity extends Actionbaractivity {@ overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.activity_main); ImageView ImageView = (ImageView) Findviewbyid (R.id.imageview); Glide.with (this). Load (r.drawable.loading). to (ImageView);}}

Where r.drawable.loading is the Loading.gif diagram loaded in the drawable directory:




Load GIF Resource Graph into Android ImageView based on open source framework Glide

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.