SmartImageView的设计初衷是来取代Android自带的ImgageView组件,另外它还提供了一些附加功能,如:
支持通过URL来加载图片;
支持从电话簿中加载图片;
异步加载图片;
图片被缓存在内存,以便下次快速加载显示;
SmartImageView类可以被很容易扩展成对其它资源的调用;

当我们在布局文件中使用ImageView时,可以直接写,那是因为这个类是包含在android.jar的包里面,使用自定义的时候,一定要加上包名;
获取SmartImageView对象,通过findViewById()方法,
调用SmartImageView对象的setImageUrl(url,fallbackResource,loadingResource)方法,参数:url是String类型的图片路径,另两个一个是下载失败时显示和正在下载时显示的int类型的资源id

这里写代码片activity_main:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/activity_main"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context="cn.edu.bzu.imagev.MainActivity"><com.loopj.android.image.SmartImageView
        android:id="@+id/iv"android:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_weight="1000" /><EditText
        android:id="@+id/et_path"android:layout_width="fill_parent"android:layout_height="wrap_content"android:hint="请输入图片路径"android:singleLine="true"android:text="http://b.hiphotos.baidu.com/image/w%3D310/sign=a439f5b24510b912bfc1f0fff3fdfcb5/83025aafa40f4bfb92c52c5d014f78f0f73618a5.jpg" /><Button
        android:layout_width="fill_parent"android:layout_height="wrap_content"android:onClick="click"android:text="浏览" />
</LinearLayout>
这里写代码片
MainActivity:
package cn.edu.bzu.imagev;import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;import com.loopj.android.image.SmartImageView;public class MainActivity extends AppCompatActivity {private EditText et_path;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);et_path=(EditText)findViewById(R.id.et_path);}public void click(View view){SmartImageView iv=(SmartImageView)findViewById(R.id.iv);iv.setImageUrl(et_path.getText().toString());}
}
这里写代码片AndroidManifest:<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="cn.edu.bzu.imagev"><application
        android:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:supportsRtl="true"android:theme="@style/AppTheme"><activity android:name=".MainActivity"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

SmartImageView相关推荐

  1. Android图像开源视图:SmartImageView

    项目需要,开发中需要加载图片,自己要写图片从网上下载的方法,还要写缓存,等等. 在网上找到一个开源项目,smartImageVIew,支持从URL和通讯录中获取图像,可以替代Android标准的Ima ...

  2. SmartImageView框架的使用

    2016-01-07 项目需要,开发中需要加载图片,自己要写图片从网上下载的方法,还要写缓存,等等. 在网上找到一个开源项目,smartImageVIew,支持从URL和通讯录中获取图像,可以替代An ...

  3. Android smartimageview网络图片查看器

    调用代码: SmartImageView siv = (SmartImageView) findViewById(R.id.siv);siv.setImageUrl(et_path.getText() ...

  4. 【Android之SmartImageView图片控件】

    源码地址是https://github.com/loopj/android-smart-image-view,没有sample,本文最后会提供一个sample. smartimageview提供的主要 ...

  5. Anroid 加载图片方式一 使用SmartImageView

    首先到github网站下载SmartImageView,拷贝到工程 使用方式 public class SmartImageViewActivity extends BaseActivity {pri ...

  6. Android SmartImageView插件实现图片浏览功能

    源码下载↓↓↓ 在https://github.com网上找的小插件,实现图片浏览的简单功能,很方便. 额,简单的代码都没有几个了.. package com.example.imageview;im ...

  7. SmartImageView的简单使用

    SmartImageView主要是为了加速从网上加载图片,支持根据URL地址加载图片,支持异步加载图片,支持图片缓存等. 下载地址 http://loopj.com/android-smart-ima ...

  8. Android之使用SmartImageView加载图片

    在网络编程的时候,我们总要加载图片,往往拿到的不是图片,而是图片的链接,这时候我们就要使用SmartImageView来加载图片了 这是一种便捷的方式~ 那如何使用呢~ 看下面代码: public c ...

  9. Android应用开发:网络编程-1

    网络编程 Java基础:网络编程 Uri.URL.UriMatcher.ContentUris详解 Android应用开发:网络编程1 Android应用开发:网络编程2 1. 请求网络图片 网络交互 ...

  10. Xml 格式数据的生成和解析

    相关阅读 XML约束 Xml 格式数据的生成和解析 XML解析器 什么是XML XML全称为Extensible Markup Language, 意思是可扩展的标记语言,它是 SGML(标准通用标记 ...

最新文章

  1. 滴滴海外市业务面试经历
  2. 《 Java并发编程从入门到精通》Thread安全与不安全
  3. Android --- 选项卡背景样式,左侧边有颜色
  4. SpringCloud-创建服务消费者-Ribbon方式(附代码下载)
  5. ABI(Application Binary Interface)
  6. 各主流浏览器内核介绍
  7. FB接连出事儿?上亿用户记录在亚马逊云服务器上就公之于众了……下滑到第七?领英说苹果怎么就不受雇员欢迎了呢? | 极客头条...
  8. VBScript:登录脚本
  9. 图论 —— 生成树 —— 最小瓶颈生成树
  10. pandas 数据处理进阶
  11. Python+VSCode是我的心头爱,飞一般的Coding体验!
  12. 网站Banner图切换效果(flash)
  13. MySQL:动态开启慢查询日志(Slow Query Log)
  14. IDEA创建maven聚合项目多模块项目并在Tomcat启动图解详细教程
  15. latex 图片整行居中 /centering无效
  16. C++ 使用其它文件的类
  17. Arkeia Software宣布支持第100个Linux平台
  18. 多表联查时的条件筛选
  19. 【赠书】腾讯广告算法大赛冠军、Kaggle Grandmaster倾力打造,涵盖Kaggle、阿里天池等赛题...
  20. IDEA使用java开发时一个奇葩问题

热门文章

  1. 信号完整性Sigrity2018各组件功能介绍
  2. Crypto-js加密解密
  3. python如何上传文件_Python 上传文件
  4. R语言学习之R程序包安装
  5. 3D数学基础:图形与游戏开发 【第一章 简介】
  6. 蓝桥杯题目练习 水题 [蓝桥杯2019初赛]矩形切割
  7. Java项目从开发到部署生产完整流程梳理
  8. Mybatis-Plus 自定义 id 生成器
  9. Fortran 95 数据类型、输入输出、声明
  10. 富士通MB95F636H输出PWM