因此,您将这些图像放入 {*}dpi 文件夹中。对吗?正如您可能已经知道的那样,您将正常分辨率(最适合您的应用程序的分辨率 - 设备大小和分辨率)图像放入“mdpi”文件夹。如果您的应用程序在具有非常高分辨率的超大设备中启动( xdpi) ,它会将图像放大到 2.0 的比例,如果设备大且高分辨率 (hdpi),它会将图像放大到 1.5 的比例。如果设备具有低 dpi 和小尺寸,android 会将图像尺寸压缩到 0.75 比例。但是,如果这对您来说还不够(对我来说还不够),您可以简单地找出目标设备的分辨率并根据自己调整图像的大小.. 您所要做的就是找出(必须计算它)为自己)常数调整图像的分辨率。例如; 0.6(根据发现的屏幕分辨率,您将图像的宽度和高度乘以该常数。这是我的示例:
Display currentScreen = this.getWindowManager().getDefaultDisplay();
Point dimension = new Point();
currentScreen.getSize(dimension);
//int widthPixel = dimension.x;
int heightPixel = dimension.y;
System.out.println("Screen Resolution (Height) : "+heightPixel);
int imgHeight;
imgHeight = (int) Math.floor(heightPixel * 0.6);
int widthSeparator = (int) dimension.y/13;
System.out.println("Width Separator : "+widthSeparator);
//imgHeight = 240;
System.out.println("Image Resolution (Height) : "+imgHeight);
FrameLayout.LayoutParams layoutParamCR = new FrameLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layoutParamCR.setMargins(widthSeparator, 0, 0, 0);
//FrameLayout.LayoutParams layoutParamL = new FrameLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
//layoutParamL.setMargins(-30, 0, 0, 0);
ImageView leftCover = (ImageView) findViewById(R.id.magCoverLeft);
leftCover.setAdjustViewBounds(true);
leftCover.setMaxHeight(imgHeight);
leftCover.setLayoutParams(layoutParamCR);
leftCover.setImageBitmap(null);
ImageView cover = (ImageView) findViewById(R.id.magCover);
cover.setAdjustViewBounds(true);
cover.setMaxHeight(imgHeight);
cover.setLayoutParams(layoutParamCR);
cover.setImageBitmap(coverImages[0]);
ImageView rightCover = (ImageView) findViewById(R.id.magCoverRight);
rightCover.setAdjustViewBounds(true);
rightCover.setMaxHeight(imgHeight);
rightCover.setLayoutParams(layoutParamCR);
rightCover.setImageBitmap(coverImages[1]);