Explain the basic use of Android image loading framework fresco (I)

PS: fresco has been a popular image loading framework for a while. I heard that the internal implementation is very awesome, although I haven't studied the principle. But first I learned the basic functions and felt the power of this framework. This article only talks about the usage of setting attributes in XML

0. Introduce fresco and relevant precautions.

1. Placeholderimage bitmap

2. Picture displayed when failureimage fails to load

3. Retryimage reloaded pictures

4. Progress picture displayed when progressbarimage is loaded

5. Backgroundimage background

6. Overlayimage overlay

7. Load pictures with multiple effects

8. Round head, rounded head and background overlay

9. Image border

First, briefly introduce fresco. If you just want to load network pictures and display some special effects, simpledraweeview can basically meet our needs. Fresco uses image pipeline to manage and obtain pictures, and simpledraweeview is a package of ImageView, In addition, image pipeline is used internally to manage images. Therefore, if we have no special needs, we try to use simpledraweeview. This is also a suggestion on the official website.

Core classes: draweeview (subclass: simpledraweeview), draweehierarchy (subclass: genericdraweehierarchy), draweecontroller. (similar to MVC)

I basically use these three classes here. Draweehierarchy, draweecontroller uses the build mode to instantiate objects. The core classes are basically introduced. Here is just a brief introduction, not involving principles.

0. Introduction of fresco

compile 'com.facebook.fresco:fresco:0.14.0'

The introduction of fresco is relatively simple. We only need to add it in build.gradle. The demo provided on GitHub is difficult to extract, and it does not have too much effect in actual operation. It only compares the performance of multiple picture loading frameworks when loading pictures. If you want to see the official operation effect. The source code will be provided at the end of the article.

One thing to note is that we need to initialize before using fresco. It should be placed before the layout is loaded, otherwise an error will occur when setcontentview parses XML.

@Override
protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 Fresco.initialize(this);
 setContentView(R.layout.activity_simple_drawee);
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>