fresco的gif动画

// 一般依赖:
compile ‘com.facebook.fresco:fresco:0.14.1’
compile ‘com.facebook.fresco:animated-gif:0.14.1’

//初始化
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Fresco.initialize(this);
}
}

//布局

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout xmlns:android=“http://schemas.android.com/apk/res/android
xmlns:fresco=“http://schemas.android.com/apk/res-auto
xmlns:tools=“http://schemas.android.com/tools
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=".MainActivity">

<com.facebook.drawee.view.SimpleDraweeView
    android:id="@+id/image"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:scaleType="centerCrop"
    fresco:roundAsCircle="true"/>

</android.support.constraint.ConstraintLayout>

//代码
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SimpleDraweeView image = findViewById(R.id.image);
    DraweeController draweeController = Fresco.newDraweeControllerBuilder()
            .setAutoPlayAnimations(true)
            .setUri(Uri.parse("http://img5.hao123.com/data/1_d2fc6722158a39d50d64b982abfb0e86_0"))
            .build();
    image.setController(draweeController);
}

}

猜你喜欢

转载自blog.csdn.net/weixin_42791904/article/details/84566720