Android supports third-party class with image suffix .gif

Source: Internet
Author: User

From Open Source China

Gifview is a view that does not directly display GIF images in Android. It can only be displayed through mediaplay. It is the same as imageview and supports GIF images.

Usage:

1-add gifview. jar to your project.

2-configure the basic attributes of GIF view in XML. gif view inherits from the View class, which is a UI control like button and imageview. For example:

<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 attributes in the Code:

// Get the gifview handle from XML
Gf1 = (gifview) findviewbyid(r.id.gif 1 );
// Set the GIF Image Source
Gf1.setgifimage(r.drawable.gif 1 );
// Add listener
Gf1.setonclicklistener (this );
// Set the display size, stretch, or compress
Gf1.setshowdimension (300,300 );
// Set the loading mode: First load and then display, while loading, only display the first frame and then display
Gf1.setgifimagetype (gifimagetype. cover );

The Jar package of GifView has four classes:

GifAction. java observer class to monitor whether the GIF is loaded successfully

Three members in GifFrame. java: current image, latency, And next Frame link.

GifDecoder. java decoding Thread class

GifView. java main class, including common methods, such as the GifView constructor, image source setting, latency, and painting.

Related Article

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.