1,studio添加fresco的jar包依赖使用括号里面的就行(compil 'com.facebook.fresco:fresco:0.8.1') 加载gif不要用高版本的Fresco;
2,写xml文件
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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="com.example.myapplication.MainActivity"> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/sim_fre" android:layout_width="200dp" android:layout_height="200dp" fresco:placeholderImage="@mipmap/ic_launcher"/> </RelativeLayout>3,代码中加载
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fresco.initialize(this);//初始化在加载布局的上面 setContentView(R.layout.activity_main); SimpleDraweeView s=(SimpleDraweeView)this.findViewById(R.id.sim_fre); DraweeController mDraweeController = Fresco.newDraweeControllerBuilder() .setAutoPlayAnimations(true) //设置uri,加载本地的gif资源 .setUri(Uri.parse("res://"+getPackageName()+"/"+R.drawable.e))//设置uri .build(); //设置Controller s.setController(mDraweeController); } }4,结束,简单的加载动图,共同研究,共同进步;