朋友们,
我正在使用以下代码来调整图像大小
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;
}
来自互联网。现在它在高分辨率屏幕上工作正常,但在小屏幕上它没有任何人指导我应该怎么做才能根据屏幕分辨率显示图像?