图片加载框架

本文介绍了三种流行的图片加载框架Glide、Picasso和Fresco的基本使用方法。这些框架简化了图片加载过程,支持多种图片格式,并提供了缓存机制,提高了应用程序性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

图片加载框架  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图片等




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凉亭下

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值