日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

【Android 应用开发】分析各种Android设备屏幕分辨率与适配 - 使用大量真实安卓设备采集真实数据统计

發(fā)布時(shí)間:2025/6/17 54 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Android 应用开发】分析各种Android设备屏幕分辨率与适配 - 使用大量真实安卓设备采集真实数据统计 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

.主要是為了總結(jié)一下 對(duì)這些概念有個(gè)直觀的認(rèn)識(shí);


.

作者 : 萬(wàn)境絕塵?

轉(zhuǎn)載請(qǐng)注明出處 :?http://blog.csdn.net/shulianghan/article/details/19899193

.


一. 數(shù)據(jù)采集



源碼GitHub地址 :?

-- SSH :?git@github.com:han1202012/DisplayTest.git;

-- HTTP :?https://github.com/han1202012/DisplayTest;


.

使用下面的程序運(yùn)行在不同設(shè)備上 :?

package shuliang.han.displaytest;import android.app.Activity; import android.os.Bundle; import android.util.DisplayMetrics;public class MainActivity extends Activity {//屏幕的寬高, 單位像素private int screenWidth;private int screenHeight;//屏幕的密度private float density; //只有五種情況 : 0.75/ 1.0/ 1.5/ 2.0/ 3.0private int densityDpi; //只有五種情況 : 120/ 160/ 240/ 320/ 480//水平垂直精確密度private float xdpi; //水平方向上的準(zhǔn)確密度, 即每英寸的像素點(diǎn)private float ydpi; //垂直方向上的準(zhǔn)確密度, 即沒(méi)音村的像素點(diǎn)@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// getPixelWindowManager(); // getPixelDisplayMetrics();getPixelDisplayMetricsII();System.out.println("寬:" + screenWidth + ", 高:"+screenHeight);System.out.println("密度 density:" + density + ",densityDpi:" +densityDpi);System.out.println("精確密度 xdpi:" + xdpi + ", ydpi:" + ydpi);}private void getPixelWindowManager() {screenWidth = getWindowManager().getDefaultDisplay().getWidth();screenHeight = getWindowManager().getDefaultDisplay().getHeight();}private void getPixelDisplayMetrics() {DisplayMetrics dm = new DisplayMetrics();dm = getResources().getDisplayMetrics();screenWidth = dm.widthPixels;screenHeight = dm.heightPixels;density = dm.density;densityDpi = dm.densityDpi;xdpi = dm.xdpi;ydpi = dm.ydpi;}private void getPixelDisplayMetricsII() {DisplayMetrics dm = new DisplayMetrics();getWindowManager().getDefaultDisplay().getMetrics(dm);screenWidth = dm.widthPixels;screenHeight = dm.heightPixels;density = dm.density;densityDpi = dm.densityDpi;xdpi = dm.xdpi;ydpi = dm.ydpi;} }


1. 三星 GT-N8000 平板


設(shè)備規(guī)格 :?

-- 屏幕尺寸 10.1英寸
-- 屏幕分辨率 WXGA TFT 1280x800
-- 屏幕比例 16:9?
-- 屏幕類型 TFT


運(yùn)行程序采集的數(shù)據(jù) :?

02-22 16:21:11.230: I/System.out(29911): 寬:1280, 高:752 02-22 16:21:11.230: I/System.out(29911): 密度 density:1.0,densityDpi:160 02-22 16:21:11.230: I/System.out(29911): 精確密度 xdpi:149.82489, ydpi:150.51852


布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="1280dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>



運(yùn)行效果 :?




2. 三星 P-601平板


設(shè)備規(guī)格 :?

-- 屏幕尺寸 : 10.1英寸
-- 屏幕分辨率 : 2560x1600
-- 屏幕比例 : 16:9
-- 屏幕類型 : TFT


運(yùn)行程序后采集的數(shù)據(jù) :?

02-28 10:30:55.338: I/System.out(18566): 寬:2560, 高:1600 02-28 10:30:55.338: I/System.out(18566): 密度 density:2.0,densityDpi:320 02-28 10:30:55.338: I/System.out(18566): 精確密度 xdpi:301.037, ydpi:301.037
布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="1280dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>
效果圖 :?



XML文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="1270dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>

效果圖 : 1280dp能布滿屏幕, 1270dp差一點(diǎn)布滿屏幕;






3. 三星Galaaxy Note3 SM-N9002


設(shè)備規(guī)格 :?

-- 屏幕尺寸 :?5.7英寸
-- 屏幕色彩 :?1600萬(wàn)色
-- 屏幕材質(zhì) :?Super AMOLED
-- 分辨率 :?1920*1080
-- 觸摸屏 :?電容屏


運(yùn)行程序采集的數(shù)據(jù) :?

02-28 10:37:48.960: I/System.out(5770): 寬:1080, 高:1920 02-28 10:37:48.960: I/System.out(5770): 密度 density:3.0,densityDpi:480 02-28 10:37:48.960: I/System.out(5770): 精確密度 xdpi:386.366, ydpi:387.047
XML布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="360dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>
效果圖 : 360dp 是正好能布滿整個(gè)屏幕.



XML布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="350dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>
效果圖 : 350dp 就差一點(diǎn)布滿全屏;


.



4. 三星 GT-I9220


規(guī)格參數(shù) :?

-- 屏幕尺寸 :?6.3英寸
-- 屏幕色彩 :?1600萬(wàn)色
-- 屏幕材質(zhì) :?Super Clear LCD
-- 分辨率 :?1280 x 720


運(yùn)行程序收集的數(shù)據(jù) :?

02-28 11:09:10.848: I/System.out(17853): 寬:800, 高:1280 02-28 11:09:10.848: I/System.out(17853): 密度 density:2.0,densityDpi:320 02-28 11:09:10.848: I/System.out(17853): 精確密度 xdpi:317.5, ydpi:306.71698

XML布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="400dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>
效果圖 :?



XML布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="390dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>

效果圖 :?




5. 青橙 GO M2S


規(guī)格參數(shù) :?

-- 屏幕分辨率 : 480 X 800

-- 屏幕材質(zhì) : TFT

-- 屏幕尺寸 :?124.2×63.8×10.45毫米


運(yùn)行程序采集數(shù)據(jù) :?

02-28 11:16:08.254: I/System.out(31888): 寬:480, 高:800 02-28 11:16:08.254: I/System.out(31888): 密度 density:1.5,densityDpi:240 02-28 11:16:08.254: I/System.out(31888): 精確密度 xdpi:160.42105, ydpi:160.0
XML布局文件 : 320dp占滿全屏;

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="320dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>
效果圖 :?



XML布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="310dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>
效果圖 : 310dp差一點(diǎn)占滿全屏;



6. 聯(lián)想 s890


規(guī)格參數(shù) :?5英寸 960x540像素



運(yùn)行程序收集數(shù)據(jù) :?

02-28 11:27:27.330: I/System.out(7708): 寬:540, 高:960 02-28 11:27:27.330: I/System.out(7708): 密度 density:1.5,densityDpi:240 02-28 11:27:27.330: I/System.out(7708): 精確密度 xdpi:240.0, ydpi:240.0

XML布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="360dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>
效果圖 : 360dp 布滿全屏;



XML布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="350dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>
效果圖 : 350dp 差一點(diǎn)布滿全屏



7. 華為 D2-0082


規(guī)格參數(shù) :?

-- 屏幕尺寸 :?5.0英寸;
-- 屏幕色彩 :?1600萬(wàn)色;
-- 屏幕材質(zhì) :?IPS;
-- 分辨率 :?1920*1080;



運(yùn)行程序采集的數(shù)據(jù) :?

03-04 17:18:07.512: I/System.out(9435): 寬:1080, 高:1776 03-04 17:18:07.516: I/System.out(9435): 密度 density:3.0,densityDpi:480 03-04 17:18:07.516: I/System.out(9435): 精確密度 xdpi:442.4516, ydpi:443.34546

XML布局文件 : 360dp 布滿全屏;

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="360dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>

效果圖 :?



XML布局文件 : 350dp 橫向 差一點(diǎn)布滿全屏;

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="350dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>
效果圖 :?




8. 三星 SM-T311


屏幕規(guī)格 :?

-- 屏幕尺寸 :?8英寸
-- 屏幕分辨率 :?1280*800
-- 屏幕比例 :?16:10
-- 屏幕類型 :?TFT
-- 指取設(shè)備 :?觸摸
-- 屏幕描述 :?電容屏



運(yùn)行程序采集的數(shù)據(jù) :?

02-22 23:02:05.780: I/System.out(5053): 寬:1280, 高:800 02-22 23:02:05.780: I/System.out(5053): 密度 density:1.3312501,densityDpi:213 02-22 23:02:05.780: I/System.out(5053): 精確密度 xdpi:188.148, ydpi:187.93


213的歸一化密度 這是鬧哪樣啊 ...


計(jì)算橫向dp數(shù) : 1280 / 1.3312501 = 961.50227519 ...?

XML布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="955.5dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>
效果圖 : 差一點(diǎn)布滿全屏;



XML布局文件 :?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><TextViewandroid:layout_width="961.5dp"android:layout_height="wrap_content"android:background="#FF0000"android:text="@string/hello_world" /></LinearLayout>

效果圖 :?



.




二. 數(shù)據(jù)分析



. 型號(hào) 分辨率 密度 歸一化密度 水平物理密度 垂直物理密度


.

手機(jī)型號(hào)分辨率密度 | 寬度(dp) | 寬度(inch)歸一化密度水平精確密度垂直物理密度
三星GT-N80001280 x 8001.0 | 1280dp | 8.54in160149.82489150.51852
三星P-6012560 x 16002.0 | 1280dp | 8.49in320301.037301.037?
三星SM-N90021080 x 19203.0 | 360dp | 2.795in480386.366387.047
三星GT-I9220720 x 12802.0 | 360dp | 2.68in320317.5306.71698
青橙GO M2S480 x 8001.5 | 320dp | 2.99in240160.42105160.0?
聯(lián)想S980540 x 9601.5 | 360dp | 2.25in240240.0240.0
華為D2-00821080 x 19203.0 | 360dp | 2.44in480442.4516443.34546

. 有點(diǎn)凌亂啊, 先留著以后在總結(jié);


現(xiàn)有公式 :?

-- 像素 和 設(shè)備獨(dú)立像素 轉(zhuǎn)換公式 : px = dp * densityDpi / 160 , density 是歸一化密度;

-- 英寸數(shù) 和 分辨率 轉(zhuǎn)換公式 : in = px / real_densityDpi , dpi 是真實(shí)的物理密度;

-- 設(shè)備獨(dú)立像素 和 分辨率之間轉(zhuǎn)換 : dp = px / density ;


物理長(zhǎng)度計(jì)算 :

-- 根據(jù)設(shè)備獨(dú)立像素計(jì)算實(shí)際物理長(zhǎng)度 :?in = px / real_densityDpi ;?


.

物理密度和歸一化密度 : ?有點(diǎn)凌亂, 哪個(gè)安卓大神能解釋下為什么啊, 定義的標(biāo)準(zhǔn)時(shí)什么啊, 想怎么定義就怎么定義? 青橙手機(jī)是奇葩啊 !!! 先寫到這 ╮(╯▽╰)╭


.

作者?:?萬(wàn)境絕塵?

轉(zhuǎn)載請(qǐng)注明出處?:?http://blog.csdn.net/shulianghan/article/details/19899193

.


總結(jié)

以上是生活随笔為你收集整理的【Android 应用开发】分析各种Android设备屏幕分辨率与适配 - 使用大量真实安卓设备采集真实数据统计的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。