欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

fresco的gif动画

程序员文章站 2022-03-24 18:44:46
...

// 一般依赖:
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);
}

}

相关标签: fresco的gif动画