2012-09-12 22 views
0

我已經根據不同的限定符(如drawable-hdpi和drawable-mdpi)設計了不同的UI,如下圖所示,當我在4.3」大小的移動設備如SG2,UI與屏幕匹配。然而,當我測試4.7「像SG3和Atrix的設備有一些差距,這是不好的Android,如何設置限定符以支持4.7「設備?

所以,我想重新設計基於新維度的這些設備的屏幕我讀Supporting Multiple Screens但是,我沒有找到一個解決方案,我嘗試在drawable-xdpi中添加新的UI,但是它影響了我在4.3「設備上的當前設計。我試圖使用swdp,wdp和hdp,但結果並不令人滿意。

你有什麼建議嗎?任何建議,將不勝感激。 謝謝 enter image description here

回答

0

所以,你把這些圖片放到{*} 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]); 
+0

感謝親愛昂,圖像不存儲在設備和所有的他們來自互聯網和圖像視圖根據圖像數量動態生成。但是,我得到了你的想法。謝謝。讓我測試它看看不同的屏幕尺寸的結果是什麼... – Hesam

+0

不客氣..我以爲你的圖像位於{*} dpi文件夾中。 我的例子更適合來自Internet的圖像,因爲我是這樣寫的。 –