我使用下面的代碼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