Before writing the project used Universalimageloader,picasso and other pictures to load the frame, found that they do not support the loading GIF map, and then learned that the fresco picture loading frame, it can load GIF animated diagram, summed up its simple use.
First, the Android Studio developer adds a line of code to the dependencies:
Compile ' com.facebook.fresco:fresco:0.9.0+ '
Layout:
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
xmlns:fresco= "Http://schemas.android.com/apk/res-auto"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical" >
<!--does not support wrap_content-->
<com.facebook.drawee.view.simpledraweeview
Android:id= "@+id/user_avator1"
Android:layout_width= "100DP"
android:layout_height= "100DP"
Fresco:placeholderimage= "@mipmap/ic_launcher"/>
<!--fresco:placeholderimage= "@mipmap/ic_launcher" is a placeholder picture-->
<com.facebook.drawee.view.simpledraweeview
Android:id= "@+id/user_avator2"
Android:layout_width= "100DP"
android:layout_height= "100DP"
Fresco:placeholderimage= "@mipmap/ic_launcher"/>
</LinearLayout>
Activity:
Import android.app.Activity;
Import Android.net.Uri;
Import Android.os.Bundle;
Import Com.facebook.drawee.backends.pipeline.Fresco;
Import Com.facebook.drawee.interfaces.DraweeController;
Import Com.facebook.drawee.view.SimpleDraweeView;
public class Mainactivity extends activity {
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Fresco.initialize (mainactivity.this);//Registered, before Setcontentview.
Setcontentview (R.layout.activity_main);
Simpledraweeview simpleDraweeView1 = (simpledraweeview) Findviewbyid (R.id.user_avator1);
Simpledraweeview simpleDraweeView2 = (simpledraweeview) Findviewbyid (R.ID.USER_AVATOR2);
Uri uri = uri.parse ("Yun_qi_img/468f0fc71e49479bf021c64cefee2882.gif");
Load a static picture
Simpledraweeview1.setimageuri (URI);
Load dynamic Picture
Draweecontroller controller = Fresco.newdraweecontrollerbuilder (). Seturi (URI). Setautoplayanimations (True). Build () ;
Simpledraweeview2.setcontroller (Controller);
}
}