所以,你把這些圖片放到{*} dpi文件夾中吧? 正如您可能已經知道的那樣,您將正常分辨率(最適合您的應用程序的分辨率 - 設備大小和分辨率)圖像放入「mdpi」文件夾中。如果您的應用程序以超高分辨率在extraLarge設備中使用(xdpi),它會將圖像放大到2.0倍,如果設備大而高分辨率(hdpi),它會將圖像放大到1.5倍。如果設備具有較小的尺寸,則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]);
感謝親愛昂,圖像不存儲在設備和所有的他們來自互聯網和圖像視圖根據圖像數量動態生成。但是,我得到了你的想法。謝謝。讓我測試它看看不同的屏幕尺寸的結果是什麼... – Hesam
不客氣..我以爲你的圖像位於{*} dpi文件夾中。 我的例子更適合來自Internet的圖像,因爲我是這樣寫的。 –