我使用下面的代码resizeImage
private Bitmap resizeImage(final Bitmap image) {
Bitmap resizedImage = null;
if(image != null)
{
int maxHeight = 80; //actual image height coming from internet
int maxWidth = 150; //actual image width coming from internet
int imageHeight = image.getHeight();
if (imageHeight > maxHeight)
imageHeight = maxHeight;
int imageWidth = (imageHeight*image.getWidth())/image.getHeight();
if (imageWidth > maxWidth) {
imageWidth = maxWidth;
imageHeight = (imageWidth*image.getHeight())/image.getWidth();
}
resizedImage = Bitmap.createScaledBitmap(image, imageWidth, imageHeight, true);
}
return resizedImage;
}
来自互联网的到来。 现在它在高分辨率屏幕上工作正常,但在小屏幕上它没有任何人指导我该如何根据屏幕分辨率显示图像?
背后是什么计算imageHeigt和imageWidth逻辑??其实我在我的代码中使用你的逻辑,但是当我在我的Galaxy 10.1上运行它时,图像变得更小了.. – User42590 2013-01-01 08:27:02