Android不加载图片获取原图宽高

//获取Options对象
BitmapFactory.Options options = new BitmapFactory.Options();
//仅做解码处理,不加载到内存
options.inJustDecodeBounds = true;
//解析文件
BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"/test.png", options);
//获取宽高
int imgWidth = options.outWidth;
int imgHeight = options.outHeight;

如果你只想显示的话,我是个怀旧的人,还是喜欢用ImageLoader

ImageLoader.getInstance().displayImage(url, displayImgId);

你可能感兴趣的:(Android不加载图片获取原图宽高)