Android屏幕尺寸与度量单位(px,dp,sp)简介
MarkdownPad Document
*:first-child {
margin-top: 0 !important;
}
body>*:last-child {
margin-bottom: 0 !important;
}
/* BLOCKS
=============================================================================*/
p, blockquote, ul, ol, dl, table, pre {
margin: 15px 0;
}
/* HEADERS
=============================================================================*/
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
}
h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
font-size: inherit;
}
h1 {
font-size: 28px;
color: #000;
}
h2 {
font-size: 24px;
border-bottom: 1px solid #ccc;
color: #000;
}
h3 {
font-size: 18px;
}
h4 {
font-size: 16px;
}
h5 {
font-size: 14px;
}
h6 {
color: #777;
font-size: 14px;
}
body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
margin-top: 0;
padding-top: 0;
}
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0;
}
h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
margin-top: 10px;
}
/* LINKS
=============================================================================*/
a {
color: #4183C4;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* LISTS
=============================================================================*/
ul, ol {
padding-left: 30px;
}
ul li > :first-child,
ol li > :first-child,
ul li ul:first-of-type,
ol li ol:first-of-type,
ul li ol:first-of-type,
ol li ul:first-of-type {
margin-top: 0px;
}
ul ul, ul ol, ol ol, ol ul {
margin-bottom: 0;
}
dl {
padding: 0;
}
dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px;
}
dl dt:first-child {
padding: 0;
}
dl dt>:first-child {
margin-top: 0px;
}
dl dt>:last-child {
margin-bottom: 0px;
}
dl dd {
margin: 0 0 15px;
padding: 0 15px;
}
dl dd>:first-child {
margin-top: 0px;
}
dl dd>:last-child {
margin-bottom: 0px;
}
/* CODE
=============================================================================*/
pre, code, tt {
font-size: 12px;
font-family: Consolas, "Liberation Mono", Courier, monospace;
}
code, tt {
margin: 0 0px;
padding: 0px 0px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px;
}
pre>code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent;
}
pre {
background-color: #f8f8f8;
border: 1px solid #ccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px;
}
pre code, pre tt {
background-color: transparent;
border: none;
}
kbd {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #DDDDDD;
background-image: linear-gradient(#F1F1F1, #DDDDDD);
background-repeat: repeat-x;
border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD;
border-image: none;
border-radius: 2px 2px 2px 2px;
border-style: solid;
border-width: 1px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
line-height: 10px;
padding: 1px 4px;
}
/* QUOTES
=============================================================================*/
blockquote {
border-left: 4px solid #DDD;
padding: 0 15px;
color: #777;
}
blockquote>:first-child {
margin-top: 0px;
}
blockquote>:last-child {
margin-bottom: 0px;
}
/* HORIZONTAL RULES
=============================================================================*/
hr {
clear: both;
margin: 15px 0;
height: 0px;
overflow: hidden;
border: none;
background: transparent;
border-bottom: 4px solid #ddd;
padding: 0;
}
/* TABLES
=============================================================================*/
table th {
font-weight: bold;
}
table th, table td {
border: 1px solid #ccc;
padding: 6px 13px;
}
table tr {
border-top: 1px solid #ccc;
background-color: #fff;
}
table tr:nth-child(2n) {
background-color: #f8f8f8;
}
/* IMAGES
=============================================================================*/
img {
max-width: 100%
}
-->
1.各度量单位的含义
- px:pixels(像素)。显示器是由一个一个的像素点组成的,例如在通用显示器中,每英寸包括72个像素点;
- dp:device independent pixels(设备独立像素),不同的设备有不同的显示效果,这个和设备硬件有关;Android中,使用dp可以对目标进行自动缩放,比较方便兼容不同尺寸的设备;详见下面介绍;
- dip:和dp是一样的,Android的早期版本使用了dip这个称呼,后来改成了dp;
- pt:point,这个是一个标准的长度单位,注意与px区分,1pt=1/72英寸,主要用于印刷行业
- sp:scaled pixels,主要用于字体的大小显示,个人理解,sp其实和dp差不多,唯一的区别在于sp可以随系统字体进行放大缩小,,当在设置中选中大字体模式后,使用sp标注的字体大小会自动缩放;
- in(英寸):长度单位
- mm(毫米):长度单位
- PPI:密度单位,表示每英寸包括多少个像素点,如显示器一般为72ppi
2.像素密度
Android设备主要包括以下几种屏幕:
| 屏幕 | 宽度 | 高度 | 尺寸 | 屏幕密度 |
|---|---|---|---|---|
| QVGA | 240 | 320 | 2.6-3.0 | LOW |
| WQVGA | 240 | 400 | 3.2-3.5 | LOW |
| FWQVGA | 240 | 432 | 3.5-3.8 | LOW |
| HVGA | 320 | 480 | 3.0-3.5 | MEDIUM |
| WVGA | 480 | 800 | 3.3-4.0 | high |
| FWVGA | 480 | 854 | 3.5-4.0 | HIGH |
| wvga | 480 | 800 | 4.8-5.5 | MEDIUM |
| FWVGA | 480 | 854 | 5.0-5.8 | MEDIUM |
| VGA | 480 | 640 | 2.8 | 286ppi |
备注:目前Android默认的low=120;medium=160;high=240
设备信息有很多,具体的可以参考下面链接:
http://www.xyaz.cn/thread-71-1-1.html
3.px与dp的转换
转换公式为:
px=dp*density/160。denisty表示屏幕密度,即当density=160时,1dp = 1px = 1sp;
Android屏幕尺寸与度量单位(px,dp,sp)简介的更多相关文章
- px,dp,sp以及像素密度
px px(pixel): 像素,是指在由一个数字序列表示的图像中的一个最小单位.在Android中,无论屏幕密度多少,一个像素单位对应一个屏幕像素单位,不会根据屏幕密度自动缩放,因此一般不推荐使用p ...
- 获取Android屏幕尺寸、控件尺寸、状态栏/通知栏高度、导航栏高度
1.获取Android屏幕尺寸 我们能够通过getSize()方法获得屏幕的尺寸 Display display = getWindowManager().getDefaultDisplay(); P ...
- android屏幕适配之度量单位、屏幕分类、图标尺寸归类分析
好久没有做android项目UI的适配了,好多基本概念都已经模糊了,于是萌生了将屏幕分辨率.常用单位.常用图标尺寸等信息规整的想法,一下就是通过查询资料,自己验证的一些随笔,如有失误之处,望大家及时予 ...
- Android dp、dip、dpi、px、sp简介及相关换算,及其应用实例
屏幕分辨率:在x y轴上的像素点数.单位是px,1px=1个像素点.一般以 纵向像素×横向像素 表示,如1920*1080dpi--------------------------每英寸上 ...
- android 屏幕尺寸的理解
对android设备屏幕尺寸单位的理解 一.android移动设备(手机和平板)常用的关于屏幕的一些单位: 1.px:像素点,应该是一个统一的单位,与我们国际单位米(M)应该是一回事,它应该是屏幕尺寸 ...
- Android屏幕尺寸单位转换
最近在看Android群英传这本书,书中有一节涉及到了,屏幕尺寸与单位.觉得以后可能会用到,做个笔记. PPI(pixels per inch) ,又称为DPI,它是由对角线的像素点数除以屏幕的大小得 ...
- px,dp sp是像素、尺寸、尺寸
px:即像素,1px代表屏幕上一个物理的像素点:px单位不被建议使用,因为同样100px的图片,在不同手机上显示的实际大小可能不同,如下图所示(图片来自android developer guide, ...
- android px,dp,sp大小转换工具
package com.voole.playerlib.util; import android.content.Context; /** * Android大小单位转换工具类<br/> ...
- android px dp sp
http://www.zcool.com.cn/article/ZMTUxODQw.html
随机推荐
- owncloud
owncloud https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ [root@n1 ~]# rpm -Uvh ius-relea ...
- 1072. Gas Station (30)【最短路dijkstra】——PAT (Advanced Level) Practise
题目信息 1072. Gas Station (30) 时间限制200 ms 内存限制65536 kB 代码长度限制16000 B A gas station has to be built at s ...
- python搭建web server
假设你急需一个简单的Web Server,但你又不想去下载并安装那些复杂的HTTP服务程序,比方:Apache,ISS等.那么, Python 可能帮助你.使用Python能够完毕一个简单的内建 HT ...
- 让你完全理解base64是怎么回事
HTTP将BASE64-编码用于基本认证和摘要认证,在几种HTTP扩展中也使用了该编码. Base-64编码保证了二进制数据的安全 Base-64编码可以将任意一组字节转换为较长的常见文本字符序列,从 ...
- C++入门学习——模板
为什么须要模板? 我们已经学过重载(Overloading),对重载函数而言,C++ 通过函数參数(參数个数.參数类型)的正确匹配来调用重载函数.比如.为求两个数的最大值,我们定义 max () 函数 ...
- linux设备驱动归纳总结(八):2.match.probe.remove
linux设备驱动归纳总结(八):2.总线.设备和驱动的关系 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
- simple-framework(MaliSDK框架分析)
simple-framework(Mali SDK框架分析) 1.全部的定义及实现放在同一个命名空间中.文件包括#include一般在命名空间的外面. 总的命名空间为namespace MaliSDK ...
- 2013级C++第12周(春)项目——成员的訪问属性、多重继承
课程首页在:http://blog.csdn.net/sxhelijian/article/details/11890759,内有完整教学方案及资源链接 第一部分 程序阅读 1.阅读程序.分析类中成员 ...
- cojs 1001. [WZOI2011 S3] 消息传递
1001. [WZOI2011 S3] 消息传递 ★★ 输入文件:messagew.in 输出文件:messagew.out 简单对比时间限制:1 s 内存限制:128 MB Prob ...
- Python读取大文件(GB)
Python读取大文件(GB) - CSDN博客 https://blog.csdn.net/shudaqi2010/article/details/54017766