簡體   English   中英

如何將手機的密度與android -DPI目錄圖像匹配

[英]how to match my phone's density to android -DPI directory images

我有LG G3手機,我知道這款手機的屏幕分辨率為: 1440 x 2560 pixels, 5.5 inches (~534 ppi pixel density)

我在這里另一個問題中看到過, 不同分辨率支持android

layout-large-mdpi   (1024x600)
layout-large-tvdpi  (800x1280)
layout-large-xhdpi  (1200x1920)
layout-xlarge-mdpi  (1280x800)
layout-xlarge-xhdpi (2560x1600)

Drawings文件夾:

移動

res/drawable        (default)
res/drawable-ldpi/  (240x320 and nearer resolution)
res/drawable-mdpi/  (320x480 and nearer resolution)
res/drawable-hdpi/  (480x800, 540x960 and nearer resolution)
res/drawable-xhdpi/  (720x1280 - Samsung S3, Micromax Canvas HD etc)
res/drawable-xxhdpi/ (1080x1920 - Samsung S4, HTC one, Nexus 5, etc)

這是否意味着我需要在xxxhdpi目錄中創建圖像? 我需要確定在開始復制這么多圖片之前, mdpixxxhdpi之間是什么關系?

通過以下代碼,您可以標識設備的相應文件夾。

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
switch(metrics.densityDpi){
    case DisplayMetrics.DENSITY_LOW://ldpi
        break;
    case DisplayMetrics.DENSITY_MEDIUM://mdpi
        break;
    case DisplayMetrics.DENSITY_HIGH://hdpi similarly extra high, double extra high also //available
        break;
}

如Shiv所說,如果要在各種設備中運行,則需要復制映像。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM