fresco的使用教程
1.加载依赖
api 'org.xutils:xutils:3.5.0'
2.创建一个myapplication
public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); Fresco.initialize(this); } }
3.网络权限
<manifest ... > <uses-permission android:name="android.permission.INTERNET" /> <application ... android:label="@string/app_name" android:name=".MyApplication" > ... </application> ... </manifest>
4.布局的命名空间
<!-- 其他元素--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fresco="http://schemas.android.com/apk/res-auto" android:layout_height="match_parent" android:layout_width="match_parent">
5.布局文件
<com.facebook.drawee.view.SimpleDraweeView android:id="@+id/my_image_view" android:layout_width="130dp" android:layout_height="130dp" fresco:placeholderImage="@drawable/my_drawable" />
6.直接使用
Uri uri = Uri.parse("https://raw.githubusercontent.com/facebook/fresco/gh-pages/static/logo.png"); SimpleDraweeView draweeView = (SimpleDraweeView) findViewById(R.id.my_image_view); draweeView.setImageURI(uri);
基本直接copy官网的,更多使用看官网
https://www.fresco-cn.org/docs/getting-started.html