一:簡介
Fresco is a powerful system for displaying images in Android applications.
Fresco takes care of image loading and display, so you don't have to. It will load images from the network, local storage, or local resources, and display a placeholder until the image has arrived. It has two levels of cache; one in memory and another in internal storage.
In Android 4.x and lower, Fresco puts images in a special region of Android memory. This lets your application run faster - and suffer the dreadedOutOfMemoryErrormuch less often.
Fresco also supports:
streaming of progressive JPEGs
display of animated GIFs and WebPs
extensive customization of image loading and display
and much more!
強(qiáng)大的圖片加載庫,支持加載網(wǎng)絡(luò)圖片,本地內(nèi)存圖片或者資源圖片,同時支持兩級緩存了罪,內(nèi)存緩存和本地緩存
在Android 4.x或者更低的系統(tǒng)中锻煌,F(xiàn)resco會將圖片放到特殊的Android內(nèi)存區(qū)域圾亏,讓程序運(yùn)行更快
Fresco同時還支持JPEG GIFs等等格式哑姚,有沒有很興奮焙格,碉堡了
先上下Github地址:
https://github.com/facebook/fresco
第一步:打開AndroidStudio項(xiàng)目的Module下的build.gradle下加入:
dependencies{
compile'com.facebook.fresco:fresco:0.9.0+'
}
在清單文件下加入網(wǎng)絡(luò)權(quán)限:
在onCreate中初始化
Fresco.initialize(this);
我們再layout中增加
android:id="@+id/my_image_view"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
app:placeholderImage="@mipmap/ic_hold"
app:placeholderImageScaleType="center"
app:failureImage="@mipmap/ic_failure02"
app:failureImageScaleType="center"
app:progressBarAutoRotateInterval="5000"
app:progressBarImage="@mipmap/ic_progress"
app:progressBarImageScaleType="center"
app:roundAsCircle="true"
app:roundedCornerRadius="50dp"
app:roundingBorderColor="@android:color/holo_blue_light"
app:roundingBorderWidth="10.0dip"/>
然后我們來加載一張網(wǎng)絡(luò)圖:圖片地址是下面這個
https://github.com/white4hy/PopWin4Edit/blob/master/screenshots/device-2016-06-02-193415.png
運(yùn)行起來看一下:
例子地址: