//依赖
compile 'com.facebook.fresco:fresco:0.12.0'
//布局文件
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="100dp" />
//application注册
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
//初始化.别忘了在清单文件注册
Fresco.initialize(this);
}
}
//Activity
public class MainActivity extends AppCompatActivity {
private SimpleDraweeView im;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//获得组件
im = (SimpleDraweeView) findViewById(R.id.sdv_head_image);
//网络
im.setImageURI("http://www.cndog.net/tpb/2013-12/14/14970-6031.jpg");
//本地注册
im.setImageURI(Uri.parse("res://com.example.xsj.shipei.Adapters/" + R.mipmap.save));
}
}