2013-10-29 25 views
1

通過爲Supporting Different Densities,有4種類型的屏幕:大 - 正常在多個屏幕的Android

xhdpi 
hdpi 
mdpi 
ldpi 

我想知道究竟是什麼,這些畫面尺寸(像素)? :

normal-xhdpi      large-xhdpi 
normal-hdpi      large-hdpi 
normal-mdpi      large-mdpi 

這些屏幕尺寸由Eclipse中給出:

xhdpi : 768 x 1280 
      2560 x 1600 
      720 x 1280 

hdpi :  480 x 800 
      480 x 854 

mdpi : 1280 x 800 
      1024 x 600 
      480 x 854 
      480 x 800 
      320 x 480 

enter image description here

回答

1

這個公式的工作,我得到的屏幕大小,並將其轉換爲像素:

float scale = getBaseContext().getResources().getDisplayMetrics().density; 
int pixels = (int) (120 * scale + 0.5f); 
+0

我想知道的是這樣的:normal-xhpdi是720x1280,large-xhdpi是768x1280,等等......無論如何感謝您的代碼。 –

+1

簡單地把你的dp變量放在規模上,並使用上面的公式...你會得到答案..我提供了明確的答案。嘗試一次,讓我知道 – KOTIOS

2

看到你在混合這些概念。小型,中型,大型和XLARGE是屏幕尺寸,而LDPI,MDPI,華電國際,xhdpi,nodpi和tvdpi是屏幕密度

根據Android Developer's website

SIZE

small - Resources for small size screens. 
normal - Resources for normal size screens. (This is the baseline size.) 
large - Resources for large size screens. 
xlarge - Resources for extra large size screens. 

密度

ldpi Resources for low-density (ldpi) screens (~120dpi). 
mdpi Resources for medium-density (mdpi) screens (~160dpi). 
     (This is the baseline density.) 

hdpi Resources for high-density (hdpi) screens (~240dpi). 
xhdpi Resources for extra high-density (xhdpi) screens (~320dpi). 
nodpi Resources for all densities. These are density-independent resources. 
     The system does not scale resources tagged with this qualifier, 
     regardless of the current screen's density. 
tvdpi Resources for screens somewhere between mdpi and hdpi; approximately 
     213dpi. This is not considered a "primary" density group. It is mostly 
     intended for televisions and most apps shouldn't need it—providing mdpi and 
     hdpi resources is sufficient for most apps and the system will scale them as 
     appropriate. If you find it necessary to provide tvdpi resources, 
     you should size them at a factor of 1.33*mdpi. 
     For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi. 

現在每個si的最小分辨率澤的定義下面

xlarge screens are at least 960dp x 720dp 
large screens are at least 640dp x 480dp 
normal screens are at least 470dp x 320dp 
small screens are at least 426dp x 320dp 

而且從機器人文檔

的dp單位轉換到屏幕像素是簡單的:像素= DPS *(密度/ 160)。例如,在240 dpi屏幕上,1 dp將等於1.5個物理像素。強烈建議使用dp單位來定義應用程序的用戶界面,以此來確保在不同屏幕上正確顯示您的用戶界面。

這意味着兩個具有不同密度的不同設備可以具有相同數量的dp但不相同的像素。