if (heightRatio > 1 && widthRatio > 1)
{
if (heightRatio > widthRatio) {
bmpFactoryOptions.inSampleSize = heightRatio;
}
else {
bmpFactoryOptions.inSampleSize = widthRatio;
}
}
bmpFactoryOptions.inJustDecodeBounds = false;
bmp = BitmapFactory.decodeStream(getContentResolver().
openInputStream(imageFileUri), null, bmpFactoryOptions);
choosenImageView.setImageBitmap(bmp);
} catch (FileNotFoundException e) {
Log.v("ERROR",e.toString());
}
}
}
}
需要在项目的layout/main.xml文件中包含如下内容: