一. 数据采集

源码GitHub地址 :

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

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

.

使用下面的程序运行在不同设备上 :

  1. package shuliang.han.displaytest;
  2. import android.app.Activity;
  3. import android.os.Bundle;
  4. import android.util.DisplayMetrics;
  5. public class MainActivity extends Activity {
  6. //屏幕的宽高, 单位像素
  7. private int screenWidth;
  8. private int screenHeight;
  9. //屏幕的密度
  10. private float density;  //只有五种情况 : 0.75/ 1.0/ 1.5/ 2.0/ 3.0
  11. private int densityDpi; //只有五种情况 : 120/ 160/ 240/ 320/ 480
  12. //水平垂直精确密度
  13. private float xdpi; //水平方向上的准确密度, 即每英寸的像素点
  14. private float ydpi; //垂直方向上的准确密度, 即没音村的像素点
  15. @Override
  16. protected void onCreate(Bundle savedInstanceState) {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.activity_main);
  19. //      getPixelWindowManager();
  20. //      getPixelDisplayMetrics();
  21. getPixelDisplayMetricsII();
  22. System.out.println("宽:" + screenWidth + ", 高:"+screenHeight);
  23. System.out.println("密度 density:" + density + ",densityDpi:" +densityDpi);
  24. System.out.println("精确密度 xdpi:" + xdpi + ", ydpi:" + ydpi);
  25. }
  26. private void getPixelWindowManager() {
  27. screenWidth = getWindowManager().getDefaultDisplay().getWidth();
  28. screenHeight = getWindowManager().getDefaultDisplay().getHeight();
  29. }
  30. private void getPixelDisplayMetrics() {
  31. DisplayMetrics dm = new DisplayMetrics();
  32. dm = getResources().getDisplayMetrics();
  33. screenWidth = dm.widthPixels;
  34. screenHeight = dm.heightPixels;
  35. density = dm.density;
  36. densityDpi = dm.densityDpi;
  37. xdpi = dm.xdpi;
  38. ydpi = dm.ydpi;
  39. }
  40. private void getPixelDisplayMetricsII() {
  41. DisplayMetrics dm = new DisplayMetrics();
  42. getWindowManager().getDefaultDisplay().getMetrics(dm);
  43. screenWidth = dm.widthPixels;
  44. screenHeight = dm.heightPixels;
  45. density = dm.density;
  46. densityDpi = dm.densityDpi;
  47. xdpi = dm.xdpi;
  48. ydpi = dm.ydpi;
  49. }
  50. }

1. 三星 GT-N8000 平板

设备规格 :

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

运行程序采集的数据 :

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

布局文件 :

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="1280dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

运行效果 :

2. 三星 P-601平板

设备规格 :

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

运行程序后采集的数据 :

  1. 02-28 10:30:55.338: I/System.out(18566): 宽:2560, 高:1600
  2. 02-28 10:30:55.338: I/System.out(18566): 密度 density:2.0,densityDpi:320
  3. 02-28 10:30:55.338: I/System.out(18566): 精确密度 xdpi:301.037, ydpi:301.037

布局文件 :

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="1280dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 :

XML文件 :

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="1270dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 : 1280dp能布满屏幕, 1270dp差一点布满屏幕;

3. 三星Galaaxy Note3 SM-N9002

设备规格 :

-- 屏幕尺寸 : 5.7英寸
-- 屏幕色彩 : 1600万色
-- 屏幕材质 : Super AMOLED
-- 分辨率 : 1920*1080
-- 触摸屏 : 电容屏

运行程序采集的数据 :

  1. 02-28 10:37:48.960: I/System.out(5770): 宽:1080, 高:1920
  2. 02-28 10:37:48.960: I/System.out(5770): 密度 density:3.0,densityDpi:480
  3. 02-28 10:37:48.960: I/System.out(5770): 精确密度 xdpi:386.366, ydpi:387.047

XML布局文件 :

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="360dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 : 360dp 是正好能布满整个屏幕.

XML布局文件 :

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="350dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 : 350dp 就差一点布满全屏;

.

4. 三星 GT-I9220

规格参数 :

-- 屏幕尺寸 : 6.3英寸
-- 屏幕色彩 : 1600万色
-- 屏幕材质 : Super Clear LCD
-- 分辨率 : 1280 x 720

运行程序收集的数据 :

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

XML布局文件 :

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="400dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 :

XML布局文件 :

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="390dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 :

5. 青橙 GO M2S

规格参数 :

-- 屏幕分辨率 : 480 X 800

-- 屏幕材质 : TFT

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

运行程序采集数据 :

  1. 02-28 11:16:08.254: I/System.out(31888): 宽:480, 高:800
  2. 02-28 11:16:08.254: I/System.out(31888): 密度 density:1.5,densityDpi:240
  3. 02-28 11:16:08.254: I/System.out(31888): 精确密度 xdpi:160.42105, ydpi:160.0

XML布局文件 : 320dp占满全屏;

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="320dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 :

XML布局文件 :

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="310dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 : 310dp差一点占满全屏;

6. 联想 s890

规格参数 : 5英寸 960x540像素

运行程序收集数据 :

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

XML布局文件 :

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="360dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 : 360dp 布满全屏;

XML布局文件 :

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="350dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 : 350dp 差一点布满全屏

7. 华为 D2-0082

规格参数 :

-- 屏幕尺寸 : 5.0英寸;
-- 屏幕色彩 : 1600万色;
-- 屏幕材质 : IPS;
-- 分辨率 : 1920*1080;

运行程序采集的数据 :

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

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

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="360dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 :

XML布局文件 : 350dp 横向 差一点布满全屏;

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6. <TextView
  7. android:layout_width="350dp"
  8. android:layout_height="wrap_content"
  9. android:background="#FF0000"
  10. android:text="@string/hello_world" />
  11. </LinearLayout>

效果图 :

二. 数据分析

. 型号 分辨率 密度 归一化密度 水平物理密度 垂直物理密度

.

手机型号 分辨率 密度 | 宽度(dp) | 宽度(inch) 归一化密度 水平精确密度 垂直物理密度
三星GT-N8000 1280 x 800 1.0 | 1280dp | 8.54in 160 149.82489 150.51852
三星P-601 2560 x 1600 2.0 | 1280dp | 8.49in 320 301.037 301.037 
三星SM-N9002 1080 x 1920 3.0 | 360dp | 2.795in 480 386.366 387.047
三星GT-I9220 720 x 1280 2.0 | 360dp | 2.68in 320 317.5 306.71698
青橙GO M2S 480 x 800 1.5 | 320dp | 2.99in 240 160.42105 160.0 
联想S980 540 x 960 1.5 | 360dp | 2.25in 240 240.0 240.0
华为D2-0082 1080 x 1920 3.0 | 360dp | 2.44in 480 442.4516 443.34546

. 有点凌乱啊, 先留着以后在总结;

现有公式 :

-- 像素 和 设备独立像素 转换公式 : px = dp * densityDpi / 160 , density 是归一化密度;

-- 英寸数 和 分辨率 转换公式 : in = px / real_densityDpi , dpi 是真实的物理密度;

-- 设备独立像素 和 分辨率之间转换 : dp = px / density ;

物理长度计算 :

-- 根据设备独立像素计算实际物理长度 : in = px / real_densityDpi ;

.

物理密度和归一化密度 :  有点凌乱, 哪个安卓大神能解释下为什么啊, 定义的标准时什么啊, 想怎么定义就怎么定义? 青橙手机是奇葩啊 !!! 先写到这 ╮(╯▽╰)╭

分析各种Android设备屏幕分辨率与适配 - 使用大量真实安卓设备采集真实数据统计的更多相关文章

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

    .主要是为了总结一下 对这些概念有个直观的认识; . 作者 : 万境绝尘  转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/198 ...

  2. 获取Android设备屏幕分辨率

    1.Android 4.3引入的wm工具: a.获取Android设备屏幕分辨率: adb shell wm size b.获取android设备屏幕密度: adb shell wm density ...

  3. Android 获取屏幕分辨率

    原文:Android 获取屏幕分辨率 得到一个屏幕尺寸的三种方法如下:        // 通过WindowManager获取        DisplayMetrics dm = new Displ ...

  4. Unity3D Android手机屏幕分辨率问题

    Android手机屏幕分辨率五花八门,导致开发时不好把握,还好各个引擎对这个屏幕分辨率问题都有较好的处理方式:unity3D 也为我们提供了一个不错的解决方案. 在Unity3D 进行 android ...

  5. iOS设备屏幕分辨率分布

    iOS设备屏幕分辨率比较单一,960*640是iPhone4和4s的分辨率,占比67.4%;1024*768是iPad1和iPad2的分辨率,占比22.5%;480*320是iPhone3和3gs的分 ...

  6. Android获取屏幕分辨率及DisplayMetrics简介

    Android 可设置为随着窗口大小调整缩放比例,但即便如此,手机程序设计人员还是必须知道手机屏幕的边界,以避免缩放造成的布局变形问题. 手机的分辨率信息是手机的一项重要信息,很好的是,Android ...

  7. ios各个型号设备屏幕分辨率总结

    https://blog.csdn.net/amyloverice/article/details/79389357     iPhone: iPhone 1G 320x480 iPhone 3G 3 ...

  8. 采用CSS3 Media Query技术适应Android平板屏幕分辨率和屏幕像素密度

    采用HTML5在开发移动应用程序满足各种需求Android分辨率和屏幕的平板设备密度,这是非常麻烦的过程,最终的解决方案是使用css media query,匹配相同的时间分辨率和屏幕像素密度.上进行 ...

  9. android手机屏幕分辨率 及 sp dip(dp) px 区别 及高中低分辨率时处理

    分辨率,是指单位长度内包含的像素点的数量,它的单位通常为像素/英寸(ppi).以分辨率为1024×768的屏幕来说,即每一条水平线上包含有1024个像素点,共有768条线,即扫描列数为1024列,行数 ...

随机推荐

  1. BZOJ3091 城市旅行 LCT

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ3091 题意概括 鉴于本人语文不好,此题的描述原题很清晰,废话不多,请看原题. 可怕,原题是图片,不 ...

  2. 7-4素数环 uva 524

    #include<iostream> #include<cstdio> #include<cmath> #include<cstring> using ...

  3. coalesce :返回参数(列名)中第一个非NULL值的字段值

    示例 下面的语句返回值 34.(只返回一个值就算后面不为NULL也直接丢弃) SELECT COALESCE( NULL, 34, 13, 0 ) 备注 如果所有参数均为 NULL,则 COALESC ...

  4. POJ2417 Discrete Logging【BSGS】(模板题)

    <题目链接> 题目大意: P是素数,然后分别给你P,B,N三个数,然你求出满足这个式子的L的最小值 : BL== N (mod P). 解题分析: 这题是bsgs算法的模板题. #incl ...

  5. P2376 [USACO09OCT]津贴Allowance

    P2376 [USACO09OCT]津贴Allowance一开始想的是多重背包,但是实践不了.实际是贪心,让多c尽可能少,所以先放大的,最后让小的来弥补. #include<iostream&g ...

  6. git根据用户过滤提交记录

    使用SourceTree 使用gitk

  7. codeforces-1102e

    https://www.cnblogs.com/31415926535x/p/10439313.html 这道题很锻炼思维,,是到好题,,就是我不在状态,,没看出来线段间的关系,,学会了求一个区间里相 ...

  8. ClassLoader如何加载class?

    ClassLoader一个经常出现又让很多人望而却步的词,本文将试图以最浅显易懂的方式来讲解 ClassLoader,希望能对不了解该机制的朋友起到一点点作用. 要深入了解ClassLoader,首先 ...

  9. C++学习笔记38:事件机制

    事件基本概念 操作系统或应用程序内部发生某件事,程序的某个组件需要响应该事件,并进行特定处理 面向对象架构中,事件响应函数最可能为成员函数 问题:指向类成员函数的指针不能转换为哑型指针void *,也 ...

  10. Saltstack 安装 命令

    主机规划 10.0.0.21 master 10.0.0.22 minion 10.0.0.23 minion 基础环境 [root@10.0.0.21 ~]# cat /etc/redhat-rel ...