添加权限:
联网权限
导包:
compile 'com.facebook.fresco:fresco:0.9.0+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.bumptech.glide:glide:3.5.2'
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/sdv"
android:layout_width="200dp"
android:layout_height="200dp"
/>
<ImageView
android:id="@+id/iv_picasso"
android:layout_width="200dp"
android:src="@mipmap/ic_launcher"
android:layout_height="200dp"/>
<ImageView
android:id="@+id/iv_glide"
android:layout_width="200dp"
android:layout_marginTop="30dp"
android:src="@mipmap/ic_launcher"
android:layout_height="200dp"/>
图片网址:
private String imagePath = "http://a.hiphotos.baidu.com/image/pic/item/314e251f95cad1c847e70404733e6709c93d51b1.jpg";
private String picassoPath = "http://e.hiphotos.baidu.com/image/pic/item/ca1349540923dd54ca7e6840dd09b3de9c82488d.jpg";
private String glidePath ="http://g.hiphotos.baidu.com/image/pic/item/902397dda144ad3487bd31a1dca20cf431ad8592.jpg";
private String gif ="http://img5.duitang.com/uploads/item/201410/04/20141004224736_SUUrT.gif";
//找控件
SimpleDraweeView sdv = (SimpleDraweeView) findViewById(R.id.sdv);
Uri uri = Uri.parse(imagePath);
sdv.setImageURI(uri);
/* DraweeController mDraweeController = Fresco.newDraweeControllerBuilder()
.setAutoPlayAnimations(true)
//设置uri,加载本地的gif资源
// .setUri(Uri.parse("res://"+getPackageName()+"/"+R.mipmap.e))//设置uri
.setUri(Uri.parse(imagePath))//设置uri
.build();
//设置Controller
sdv.setController(mDraweeController);*/
ImageView iv_picasso = (ImageView) findViewById(R.id.iv_picasso);
ImageView iv_glide = (ImageView) findViewById(R.id.iv_glide);
// 流式编程 链式编程
/**
* Picasso.with(this) 单例设计模式 volatile和 final对比
*load掌握方法重载和方法重写的区别
* Picasso跟Glide区别
* 分解学,把与之相关的知识整理出来
*/
Picasso.with(this).load(gif).placeholder(R.mipmap.ic_launcher_round).error(R.mipmap.ic_launcher_round).into(iv_picasso);
Glide.with(this).load(gif).into(iv_glide);
权限添加 name
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Fresco.initialize(this);
}
}