Frescoj说明:
facebook开源的针对android应用的图片加载框架,高效和功能齐全。
- 支持加载网络,本地存储和资源图片;
- 提供三级缓存(二级memory和一级internal storage);
- 支持JPEGs,PNGs,GIFs,WEBPs等,还支持Progressive JPEG,优秀的动画支持;
- 图片圆角,scale,自定义背景,overlays等等;
- 优秀的内存管理;
- 2.3(Gingerbread)或以上。
-------------------------------------------Fresco引入包及依赖项↓↓↓↓↓----------------------------------------------
检查添加mavenCentral();
-------------------------------------------Fresco引入包及依赖项↑↑↑↑↑----------------------------------------------
-------------------------------------------Fresco使用↓↓↓↓↓----------------------------------------------
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fresco="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.ly.blogtestbutterknife.MainActivity"> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/my_image_view" android:layout_width="130dp" android:layout_height="130dp" fresco:placeholderImage="@mipmap/ic_launcher" fresco:roundedCornerRadius="5dp" /> </LinearLayout>
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fresco.initialize(this); setContentView(R.layout.activity_main); Uri uri=Uri.parse("http://b.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=6585d7a9820a19d8cb568c0106caaebd/faf2b2119313b07e63bade100ed7912397dd8ca7.jpg"); SimpleDraweeView draweeView= (SimpleDraweeView) findViewById(R.id.my_image_view); DraweeController mDraweeController = Fresco.newDraweeControllerBuilder() .setAutoPlayAnimations(true) //设置uri,加载本地的gif资源 .setUri(uri)//设置uri .build(); //设置Controller draweeView.setController(mDraweeController); }
-------------------------------------------Fresco使用↑↑↑↑↑----------------------------------------------
参考网站:https://www.fresco-cn.org/docs/getting-started.html