Android load GIF picture powerful framework (support preload, cache, also support to display static pictures, a line of code all done)

Source: Internet
Author: User

The previous project did not involve the display GIF picture function, also did not focus on the research, the recent project to use to display the GIF picture, therefore on the net a search, used after found the following several shortcomings.

1. Loading a large GIF image will cause an oom.

2. There is no preload and cache function, compared to memory consumption.

3. The function is relatively single, the GIF is displayed but the static picture cannot be displayed.

Finally, there was a powerful GIF loading framework that met all of the above flaws, supported preloading and caching, and supported the display of both static and GIF images. Here are some source code:

The XML layout is a ImageView

Call directly where needed

Glide.with (this). Load ("GIF address"). Centercrop (). into (iv_gif);//Not preloaded
Glide.with (this). Load ("GIF address"). Centercrop (). Placeholder (r.drawable.ic_launcher). Crossfade (). into (iv_gif);// There is a pre-loaded

JAR file

?

Android load GIF picture powerful framework (support preload, cache, also support to display static pictures, a line of code all done)

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.