ImageView多种显示图片的方式
2013-09-06 17:32
274 查看
自己总结的五种 方案
if (photos.size() > 0) {
Photo photo = photos.get(0);
String imagePath = ApplicationContext.getPoiImagePath();
String path = photo.getPath();
// 一种方法
LogUtil.debug(path + "_____________________");
Drawable img = BitmapDrawable
.createFromPath(imagePath + "/" + path);
imgReview.setImageDrawable(img);
// 二种方法
Bitmap bitmap = BitmapFactory.decodeFile(imagePath + "/" +path);
imgReview.setImageDrawable(img);
// 三种方案
File file = new File(imagePath + "/" + path);
Uri u = Uri.fromFile(file);
imgReview.setImageURI(u);
// 四种 方案
Bitmap bit = BitmapFactory.decodeFile(imagePath + "/" + path); //
// 自定义//路径
imgReview.setImageBitmap(bit);
imgReview.setImageDrawable(img);
// 第五种
try {
FileInputStream file1= new FileInputStream(imagePath + "/" +
path);
Bitmap bm = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;//图片的长宽都是原来的1/8
BufferedInputStream bis = new BufferedInputStream(file1);
bm = BitmapFactory.decodeStream(bis, null, options);
imgReview.setImageBitmap(bm);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
LogUtil.error(e.getMessage(), e);
}
}
if (photos.size() > 0) {
Photo photo = photos.get(0);
String imagePath = ApplicationContext.getPoiImagePath();
String path = photo.getPath();
// 一种方法
LogUtil.debug(path + "_____________________");
Drawable img = BitmapDrawable
.createFromPath(imagePath + "/" + path);
imgReview.setImageDrawable(img);
// 二种方法
Bitmap bitmap = BitmapFactory.decodeFile(imagePath + "/" +path);
imgReview.setImageDrawable(img);
// 三种方案
File file = new File(imagePath + "/" + path);
Uri u = Uri.fromFile(file);
imgReview.setImageURI(u);
// 四种 方案
Bitmap bit = BitmapFactory.decodeFile(imagePath + "/" + path); //
// 自定义//路径
imgReview.setImageBitmap(bit);
imgReview.setImageDrawable(img);
// 第五种
try {
FileInputStream file1= new FileInputStream(imagePath + "/" +
path);
Bitmap bm = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;//图片的长宽都是原来的1/8
BufferedInputStream bis = new BufferedInputStream(file1);
bm = BitmapFactory.decodeStream(bis, null, options);
imgReview.setImageBitmap(bm);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
LogUtil.error(e.getMessage(), e);
}
}
相关文章推荐
- Android学习笔记:如何设置ImageView中图片的显示方式
- android imageView 图片显示方式属性
- imageView中图片各种比例类型的显示方式的参数设置
- Android学习笔记:如何设置ImageView中图片的显示方式
- [置顶] 实现CirleImageView圆形图片的多种方式
- ImageView的Scaletype决定了图片在View上显示时的样子,如进行何种比例的缩放,及显示图片的整体还是部分,等等。 设置的方式包括: 1. 在layout xml中定义Android:s
- ImageView以淡入淡出的方式切换显示的图片
- 通过URLHttpConnection方式来取得图片,并且显示在ImageView上
- Android 设置ImageView中图片的显示方式
- android imageView 图片显示方式属性
- Android中imageView中的属性ScaleType用来显示图片的几种方式
- 通过URLHttpConnection方式来取得图片,并且显示在ImageView上
- android imageView 图片显示方式属性
- Problem:ImageView不能显示图片。
- imageView不能正确显示图片
- Glide用在CircleImageView上每次进入第一次显示默认图片
- binbinyang-----Glide用在CircleImageView上显示默认图片的问题,以及Glide让imageview自动显示成圆形头像
- ImageView图片全屏显示
- 相机获取的图片无法显示在ImageView中(解决)
- xcode8 图片imageview图片圆角不显示的bug