SmartImageView初接触
2017-06-22 22:50
351 查看
最近一直在学习从远程服务器获取图片,开始时都是手写这些处理,后来接触到了smartImageview这个插件。github获取地址:https://github.com/loopj/android-smart-image-view
官方原版插件说明
Overview
SmartImageView is a drop-in replacement for Android’s standard ImageView which additionally allows images to be loaded from URLs or the user’s contact address book. Images are cached to memory and to disk for super fast loading.
Features
Drop-in replacement for
Load images from a URL
Load images from the phone’s contact address book
Asynchronous loading of images, loading happens outside the UI thread
Images are cached to memory and to disk for super fast loading
其中用到的就是:setImageUrl()方法,该方法有好几个重载方法,用到了这个
setImageUrl(String url,int fallbackResource)
这个方法的参数解析如下:url当然是远程图片的地址,第二个参数是当获取远程图片失败时,显示的图片,是一个int类型的res下的图片的一个id
在使用时,直接在布局文件里使用SmartImageView就行,这个类继承自ImageView
官方原版插件说明
Overview
SmartImageView is a drop-in replacement for Android’s standard ImageView which additionally allows images to be loaded from URLs or the user’s contact address book. Images are cached to memory and to disk for super fast loading.
Features
Drop-in replacement for
ImageView
Load images from a URL
Load images from the phone’s contact address book
Asynchronous loading of images, loading happens outside the UI thread
Images are cached to memory and to disk for super fast loading
SmartImageclass is easily extendable to load from other sources
其中用到的就是:setImageUrl()方法,该方法有好几个重载方法,用到了这个
setImageUrl(String url,int fallbackResource)
这个方法的参数解析如下:url当然是远程图片的地址,第二个参数是当获取远程图片失败时,显示的图片,是一个int类型的res下的图片的一个id
在使用时,直接在布局文件里使用SmartImageView就行,这个类继承自ImageView
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.yuanlp.smartimageview.loopj.android.image.SmartImageView android:id="@+id/siv" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>在MainActivity 中
com.yuanlp.smartimageviewandroid.support.v7.app.AppCompatActivityandroid.os.Bundlecom.yuanlp.smartimageview.loopj.android.image.SmartImageViewMainActivity AppCompatActivity { (Bundle savedInstanceState) { .onCreate(savedInstanceState)setContentView(R.layout.)SmartImageView siv=(SmartImageView) findViewById(R.id.)siv.setImageUrl(R.drawable.)} }
相关文章推荐
- Bochs虚拟机的使用及Linux的初步接触
- android 开发中接触的各种网络请求框架总结
- ASP注入漏洞全接触(转东转西)
- 【Spring】1.Spring初接触
- ADO第一次亲密接触
- react-native 初步接触要点总结
- ASP开发中存储过程应用全接触
- 初步接触接口设计模式以及接口和抽象类的比较
- 全面接触SQL语法(7)
- jira配置初接触记录
- 开始接触游戏制作
- docker初接触
- winform下制作第一张水晶报表 (转自weekzero博客.经测试,没有问题.对于从来没有接触过的朋友来说,值得一看.)
- 毕设期间接触的IDE&工具等(持续更新)
- 最亲密接触Dhtml&JScript开发细节
- 【菜鸟教程】小白接触白鹭引擎4天,成功做了一款足球小游戏
- ADO第一次亲密接触 -- ADO开发实践之一
- 亲密接触VC6.0编译器
- 我与龙芯电脑的第一次亲密接触
- 俺和Vista的第一次接触