.主要是为了总结一下 对这些概念有个直观的认识;

.

作者 : 万境绝尘 

转载请注明出处http://blog.csdn.net/shulianghan/article/details/19899193

.

一. 数据采集

源码GitHub地址 :

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

-- HTTPhttps://github.com/han1202012/DisplayTest;

.

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

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.0
	private int densityDpi;	//只有五种情况 : 120/ 160/ 240/ 320/ 480

	//水平垂直精确密度
	private float xdpi;	//水平方向上的准确密度, 即每英寸的像素点
	private float ydpi;	//垂直方向上的准确密度, 即没音村的像素点

	@Override
	protected 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 平板

设备规格 :

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

运行程序采集的数据 :

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" >

    <TextView
        android:layout_width="1280dp"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:text="@string/hello_world" />

</LinearLayout>

运行效果

2. 三星 P-601平板

设备规格 :

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

运行程序后采集的数据 :

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" >

    <TextView
        android: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" >

    <TextView
        android:layout_width="1270dp"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:text="@string/hello_world" />

</LinearLayout>

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

3. 三星Galaaxy Note3 SM-N9002

设备规格 :

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

运行程序采集的数据 :

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" >

    <TextView
        android: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" >

    <TextView
        android:layout_width="350dp"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:text="@string/hello_world" />

</LinearLayout>

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

.

4. 三星 GT-I9220

规格参数 :

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

运行程序收集的数据 :

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" >

    <TextView
        android: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" >

    <TextView
        android:layout_width="390dp"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:text="@string/hello_world" />

</LinearLayout>

效果图 :

5. 青橙 GO M2S

规格参数 :

-- 屏幕分辨率 : 480 X 800

-- 屏幕材质 : TFT

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

运行程序采集数据 :

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" >

    <TextView
        android: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" >

    <TextView
        android:layout_width="310dp"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:text="@string/hello_world" />

</LinearLayout>

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

6. 联想 s890

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

运行程序收集数据 :

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" >

    <TextView
        android: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" >

    <TextView
        android:layout_width="350dp"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:text="@string/hello_world" />

</LinearLayout>

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

7. 华为 D2-0082

规格参数 :

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

运行程序采集的数据 :

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" >

    <TextView
        android:layout_width="360dp"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:text="@string/hello_world" />

</LinearLayout>

效果图 :

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

<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" >

    <TextView
        android:layout_width="350dp"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:text="@string/hello_world" />

</LinearLayout>

效果图

8. 三星 SM-T311

屏幕规格 :

-- 屏幕尺寸 : 8英寸
-- 屏幕分辨率 : 1280*800
-- 屏幕比例 : 16:10
-- 屏幕类型 : TFT
-- 指取设备 : 触摸
-- 屏幕描述 : 电容屏

运行程序采集的数据 :

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的归一化密度 这是闹哪样啊 ...

计算横向dp数 : 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" >

    <TextView
        android:layout_width="955.5dp"
        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" >

    <TextView
        android:layout_width="961.5dp"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:text="@string/hello_world" />

</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 ;

.

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

.

作者 : 万境绝尘 

转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/19899193

.

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

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

    一. 数据采集 源码GitHub地址 : -- SSH : git@github.com:han1202012/DisplayTest.git; -- HTTP : https://github.co ...

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

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

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

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

  4. Android采访开发——2.通用Android基础笔试题

    注意finddreams博客: http://blog.csdn.net/finddreams/article/details/44219231 正值跳槽的热季.整理一下Android面试中最常考的笔 ...

  5. 【Android 系统开发】 编译 Android文件系统 u-boot 内核 并烧写到 OK-6410A 开发板上

    博客地址 : http://blog.csdn.net/shulianghan/article/details/40299813  本篇文章中用到的工具源码下载 : -- ok-6410A 附带的 A ...

  6. 【Android 应用开发】对Android体系结构的理解--后续会补充

    1.最底层_硬件 任何Android设备最底层的硬件包括 显示屏, wifi ,存储设备 等. Android最底层的硬件会根据需要进行裁剪,选择自己需要的硬件. 2.Linux内核层 该层主要对硬件 ...

  7. [Android Pro] 开发一流的 Android SDK:Fabric SDK 的创建经验

    cp from : https://academy.realm.io/cn/posts/oredev-ty-smith-building-android-sdks-fabric/ Ty Smith T ...

  8. Android源码分析一 Android系统架构

    一 Android系统架构 Linux内核层(Linux Kernel):Android系统基于Linux2.6内核,这一层为Android设备各种硬件提供了底层驱动,如显示驱动.音频驱动.照相机驱动 ...

  9. IDEA搭建Android wear开发环境,Android wear,I&#39;m comming!

    随着google公布了android wear这个东西.然后又有了三星的gear,LG的G watch以及moto 360,苹果由公布了apple watch.未来可能在智能手表行业又有一场战争. 当 ...

随机推荐

  1. chromium出现输入密码解锁登录密钥环

    chromium出现输入密码解锁登录密钥环 在ubuntu 16.04上安装了Chromium出现对话框,如下所示: 因为密码框截图困难,这个是网上图片. 点取消就可以使用,但是每次都这样很烦,百度后 ...

  2. hive数据类型及其数据转换

    由于需要使用hive sql进行数据查询,同时涉及多个不同类型的字段的组合,看Hive sql的文档相关和资料才知道,hive是支持大部分基础数据类型之间的相互转换的. 那么,hive本身支持哪些数据 ...

  3. [lua]写个简单的Lua拓展-sleep函数

    这几天在做一个小项目,其中用到了一些基本的API, 例如sleep,获取当前目录等等,lua标准库中没有提供这些接口,虽然所第三方库中也都有实现,但是要用的就那么几个函数,在一个嵌入式系统中安装那么多 ...

  4. Android Multimedia框架总结(五)多媒体基础概念

    转载请把头部出处链接和尾部二维码一起转载,本文出自: http://blog.csdn.net/hejjunlin/article/details/52431887 上篇中介绍了MediaPlayer ...

  5. GDAL库扩展Landsat系列MTL文件格式支持

    Landsat系列卫星提供的数据,一般都是每个波段一个tif文件,然后外加一个MTL.txt的元数据文件,使用gdal可以直接打开每个波段的tif文件,但是有时候想在打开tif数据的同时能够自动读取M ...

  6. Android高级控件(六)——自定义ListView高仿一个QQ可拖拽列表的实现

    Android高级控件(六)--自定义ListView高仿一个QQ可拖拽列表的实现 我们做一些好友列表或者商品列表的时候,居多的需求可能就是需要列表拖拽了,而我们选择了ListView,也是因为使用L ...

  7. Github客户端以及Git shell的使用

    昨天介绍了怎么使用Git Shell来commit我们的代码,但是这都是简单的操作,我们还没有使用到Github是怎么进行版本控制的呢.所以,今天就来介绍一下,怎么来做版本控制吧. 必备材料 首先要确 ...

  8. Cocos2D中Action的进阶使用技巧(二)

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 上回说到解决办法是使用CCTargetedAction类. C ...

  9. 安卓java.lang.IllegalArgumentException: The observer is null.解决方案

    刚刚在调试自己的APP项目的时候报错java.lang.IllegalArgumentException: The observer is null.,而之前是可以运行通过,所以百思不得其解,后来在网 ...

  10. div效果很好的遮盖层效果

    [html] view plaincopyprint? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...