首页 > 系统 > Android > 正文

Android加载图片框架Picasso

2019-11-08 00:22:25
字体:
来源:转载
供稿:网友

        1、在module的build.gradle文件中,添加Picasso依赖。

compile 'com.squareup.picasso:picasso:2.3.2'        2、在manifest文件中,添加加载图片所需要的权限。

网络权限

<uses-permission android:name="android.permission.INTERNET"/>SD卡读写权限

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>        3、加载资源文件图片

Picasso.with (this).load (R.mipmap.ic_launcher).into (iv);        4、加载本地图片

Picasso.with (this).load (new File ("/sdcard/download/a.png")).into (iv);        5、加载网络图片

Picasso.with (this).load ("https://www.baidu.com/img/bd_logo1.png").into (iv);        6、正在加载时,显示图片。

.placeholder (R.mipmap.ic_launcher)        7、加载图片失败时,显示图片。

.error (R.mipmap.ic_launcher)


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表