old王讲课的第六天

本文介绍了在Android平台上常用的图片加载库如ImageLoader、Picasso、Fresco和Glide的特点,包括ImageLoader的早期支持、Picasso的轻量特性、Glide的高级功能以及适配器和主页面的重要性。
摘要由CSDN通过智能技术生成

Android上图片加载的解决方案有多种,比较流行的有ImageLoader,Picasso,Fresco,Glide。

lmageLoader是很早的图片加载框架,支持图片下载进度的监听,支持View滚动过程中暂停加载。支持多种缓存策略比如最大先删除,最少使用先删除等。

Picasso简洁轻量,支持图片缓存使用的监控,支持优先级处理,支持延迟加载,自己不参与本地缓存而是交给OkHttp去实现。

public class GlideUtil {
    public static void loadImage(Context context, String path, ImageView imageView){
        Glide.with(context)
                .load(path)
                .error(R.drawable.ic_launcher_foreground)
                .placeholder(R.drawable.ic_autorenew)
                .thumbnail(0.2f)
                .skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(imageView);
    }
    //圆形图片
    public static void loadciecleImage(Context context, String path, ImageView imageView){
        Glide.with(context)
                .load(path)
                .error(R.drawable.ic_launcher_foreground)
                .placeholder(R.drawable.ic_autorenew)
                .thumbnail(0.2f)
                .circleCrop()
                .skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(imageView);
    }
    //圆角图片
    public static void loadcornerImage(Context context, String path, ImageView imageView){
        Glide.with(context)
                .load(path)
                .error(R.drawable.ic_launcher_foreground)
                .placeholder(R.drawable.ic_autorenew)
                .thumbnail(0.2f)
                .transform(new RoundedCorners(20))
                .skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(imageView);
    }
}

Entity里需要加的东西:

适配器需要写的东西有很多,但是都是必要的:

播放视频需要的代码,链接抖音:

最重要的是主页面:

  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值