使用说明:

1Gradle

dependencies {

compile 'com.facebook.fresco:fresco:0.7.0+'

}

2XML

<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:gravity="center_horizontal"

              android:orientation="vertical">

    <Button

        android:id="@+id/xml_bt_xml_gif"

        android:layout_width="match_parent"

        android:layout_height="45dp"

        android:text="播放/暂停"/>

    <com.facebook.drawee.view.SimpleDraweeView

        android:layout_width="100dp"

        android:layout_height="1100dp"

        fresco:placeholderImage="@mipmap/icon_gif"

        android:id="@+id/sdv_gif"/>

</LinearLayout>

 

3设置播放

设置DraweeController 的setAutoPlayAnimations(true) 为true,自动播放

draweeController= Fresco.newDraweeControllerBuilder()

                .setAutoPlayAnimations(true)

                .setUri(Uri.parse(uri))//设置uri

                .build();

simpleDraweeView.setController(draweeController);

4控制播放

Animatable animatable=draweeController.getAnimatable();

if (animatable.isRunning()){

        animatable.stop();

 }else{

        animatable.start();

 }

https://mp.weixin.qq.com/s/VUo_buo3Hgnv8ioO3elfDw