图片加载框架

来源:互联网 发布:java线程教程 编辑:程序博客网 时间:2024/06/11 03:57

图片加载框架  Fresco/Glide/Picasso

一、Glide的基本使用:(地址:https://github.com/Masterminds/glide)
1.引包:
dependencies {  compile 'com.github.bumptech.glide:glide:3.7.0'  compile 'com.android.support:support-v4:19.1.0'}
如需代码混淆
-keep public class * implements com.bumptech.glide.module.GlideModule-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {  **[] $VALUES;  public *;}# for DexGuard only-keepresourcexmlelements manifest/application/meta-data@value=GlideModule

 ImageView imageView = (ImageView) findViewById(R.id.my_image_view);  Glide.with(this).load("http://goo.gl/gEgYUd").into(imageView);

二、Picasso的基本使用(地址:https://github.com/square/picasso)
1.引包
compile 'com.squareup.picasso:picasso:2.5.2'
代码混淆添加:
-dontwarn com.squareup.okhttp.**
开始使用:
ImageView imageView = (ImageView) findViewById(R.id.my_image_view);Picasso.with(this).load("http://goo.gl/gEgYUd").into(imageView);
三、Fresson(地址:https://github.com/facebook/fresco)
  1.引包:
   
compile 'com.facebook.fresco:fresco:1.3.0'

首先在自定的Appcation中初始化并在AndroidManifest文件中使用

   Fresco.initialize(this);

在布局文件中添加控件:

<com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/baseline_jpeg"
          android:layout_width="match_parent"
            android:layout_height="match_parent"
        />
 
SimpleDraweeView  drawView=(SimpleDraweeView)findViewById(R.id.baseline_jpeg);

drawView.setImageUri("image_path");//设置图片地址(可以是地址、资源ID),支持jpg、webp、gif图片等




1 0