图片的缩放
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4; //长、宽分别缩放至原图的1/4
Bitmap bitmap = BitmapFactory.decodeFile(filepath, options);
viewHolder.mImageView.setImageBitmap(bitmap);
不占用内存,获取图片信息,可以认为是dummy decoder
BitmapFactory.Options
boolean inJustDecodeBounds
If set to true, the decoder will return null (no bitmap), but the out… fields will still be set, allowing the caller to query the bitmap without having to allocate the memory for its pixels.
outHeight与outWidth就是图片的长和宽。
可以先用这种方式获取长宽,然后再决定图片的尺寸。
Drawable from file
Drawable drawable = Drawable.createFromPath(filepath);
viewHolder.mImageView.setImageDrawable(drawable);
SET IMAGE WITH URI
Uri uri = Uri.fromFile(new File(filepath));
viewHolder.mImageView.setImageURI(uri);