Android Display GIF animated Gifview

Source: Internet
Author: User

animated GIF animation in Android general support is not very good, so found an open source project, is briefly described as follows:

Gifview is an item that is designed to solve the problem in Android that does not now display GIF directly, only through Mediaplay, with the same usage as ImageView, which supports GIF images
question: There is an estimated problem of oom, please think about how to avoid oom. How to use:1-Add Gifview.jar to your project. 2-Configure the basic properties of Gifview in XML, Gifview inherits from the view class, and button, ImageView, is a UI control. such as:<com.ant.liao.gifview android:id= "@+id/gif2"
android:layout_height= "Wrap_content" android:layout_width= "Wrap_content"
android:paddingtop= "4px" android:paddingleft= "14px" android:enabled= "false"/> 3-Configure common properties in your code: //Get Gifview handle from XML
GF1 = (Gifview) Findviewbyid (R.ID.GIF1);
Set up a GIF picture source
Gf1.setgifimage (R.DRAWABLE.GIF1);
Add Listener
Gf1.setonclicklistener (this);
Set the size of the display, stretch or compress
Gf1.setshowdimension (300, 300);
Set Load mode: First loaded and then displayed: Gifimagetype.Wait_finish, Side loading edge display:Gifimagetype.Sync_decoder, only the first frame is displayed again:Gifimagetype.COVERGf1.setgifimagetype (gifimagetype.cover); There are four classes of Gifview jar packages : Gifaction.java Observer class to monitor whether GIF was loaded successfully
Gifframe.java inside three members: current picture, delay, the next frame link.
Gifdecoder.java Decoding Thread classes
Gifview.java main class, including common methods, such as Gifview construction method, setting up picture source, delay, drawing, etc.

Note: Reprint to: Http://www.oschina.net/p/gifview

Annex demo+ Source code:

gifviewdemo.rar (799.31 kb, downloads: 586) src.rar (9.21 kb, download count: 260)

Improved:
1.GifView how to control the playback speed of GIF? --"modified the Systemclock.sleep in Drawthread (10);

Android Display GIF animated Gifview

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.