安卓手机屏幕基础解析

安卓手机因为其可定制性,种类繁多,给猿族的开发工作带来不少麻烦
公司里一切由美工和产品代为搞定的猿族可以绕路
一切自己动手丰衣足食的猿类可以看看
初写这种一本正经不扯淡的博客,感觉不太习惯,渣了眼镜请大家见谅

1.缘起

先从android studio中的ic_launcher说起吧
这里写图片描述
这个小机器人想必大家都很清楚了
我们来看下这几张图片的具体参数
这里写图片描述

边长比例1:1.5:2:3:4
这里边有个dpi这是什么意思呢?dpi=Dots Per Inch,顾名思义,每英寸屏幕的点数,点数即像素数.(手机屏幕就是由一个个小的正方形的像素点构成的)所以有人形象的称dpi为屏幕像素密度.
dpi代表了一个手机屏幕的精度质量.
给大家隆重介绍一个类
/**
* A structure describing general information about a display, such as its
* size, density, and font scaling.
*

To access the DisplayMetrics members, initialize an object like this:


*
 DisplayMetrics metrics = new DisplayMetrics(); 
* getWindowManager().getDefaultDisplay().getMetrics(metrics);

*/
public class DisplayMetrics {
/**
* Standard quantized DPI for low-density screens.
*/
public static final int DENSITY_LOW = 120;
/**
 * Standard quantized DPI for medium-density screens.
 */
public static final int DENSITY_MEDIUM = 160;

/**
 * This is a secondary density, added for some common screen configurations.
 * It is recommended that applications not generally target this as a first
 * class density -- that is, don't supply specific graphics for this
 * density, instead allow the platform to scale from other densities
 * (typically {@link #DENSITY_HIGH}) as
 * appropriate.  In most cases (such as using bitmaps in
 * {@link android.graphics.drawable.Drawable}) the platform
 * can perform this scaling at load time, so the only cost is some slight
 * startup runtime overhead.
 *
 * <p>This density was original introduced to correspond with a
 * 720p TV screen: the density for 1080p televisions is
 * {@link #DENSITY_XHIGH}, and the value here provides the same UI
 * size for a TV running at 720p.  It has also found use in 7" tablets,
 * when these devices have 1280x720 displays.
 */
public static final int DENSITY_TV = 213;

/**
 * Standard quantized DPI for high-density screens.
 */
public static final int DENSITY_HIGH = 240;

/**
 * Standard quantized DPI for extra-high-density screens.
 */
public static final int DENSITY_XHIGH = 320;

/**
 * Intermediate density for screens that sit somewhere between
 * {@link #DENSITY_XHIGH} (320dpi) and {@link #DENSITY_XXHIGH} (480 dpi).
 * This is not a density that applications should target, instead relying
 * on the system to scale their {@link #DENSITY_XXHIGH} assets for them.
 */
 -------------------等等等等---------------

我只截取了开头一段,但是我们可以看出,这个类规定了什么样的手机屏幕为hdpi(240);120l,160m,320xh,那么对比开始的ic_laucher的尺寸,聪明的你发现了什么?—>之后告诉UI切图的时候,这几套图的比列尺寸就这么来吧!

常见屏幕分辨率

  • VGA:Video Graphics Array,即:显示绘图矩阵,相当于640×480 像素;
  • HVGA:Half-sizeVGA,即:VGA的一半,分辨率为480×320,像三星盖世Ace S5830就是使用这分辨率;
  • QVGA:QuarterVGA,即:VGA的四分之一,分辨率为320×240,一般用于小屏手机 像三星盖世Mini S5570就是使用这分辨率;
  • WQVGA:Wide Quarter VGA,即:扩大的QVGA,分辨率比QVGA高,比VGA低,一般是:400×240,480×272;

  • WVGA:Wide Video GraphicsArray,即:扩大的VGA,分辨率为800×480像素,像三星i9000就是使用这分辨率;

  • FWVGA:Full Wide VGA ,数码产品屏幕材质的一种,VGA的另一种形式,比WVGA分辨率高,别名 : Full WideVGA, ,其分辨 率为854×480象素(16:9)。

QVGA320×240
WQVGA400×240
VGA640×480
WVGA800×480
SVGA800×600
WSVGA1024×600
XGA1024×768
WXGA1280×768/1280×800/1280*960
SXGA1280×1024
WXGA+1440×900
SXGA+1400×1050
WSXGA+1680×1050
UXGA1600×1200
WUXGA1920×1200
QXGA2048×1536
WQXGA2560×1536

现在的手机屏幕至少都在320dpi之上了,开始的时候,手机屏幕厂商感觉160dpi是个合适的标杆,可是硬件技术发展很给力,160dpi的手机都没法看了….当然,谷歌自带的模拟器还是有这个160dpi的手机的,感兴趣的可以去试试.
接下来是我 找到到介绍很细致的关于屏幕的文章,有前人写过,我就不多说了.
http://www.zcool.com.cn/article/ZNjI3NDQ=.html
http://blog.csdn.net/chinalwb/article/details/18843101
写点没有的吧,给大家看下我的小米4c的屏幕参数
这里写图片描述
然后来张模拟器的参数
这里写图片描述
好吧,看到这里你对sp是不是也看出什么端倪来了?
同样的sp单位,在dpi越高的手机上,字体越小.(这句话是错误的)

其实sp和dp是一样的,只是sp用在了字体上,dp用在了控件长度上(这句话请 大神拍砖–)

1英寸=2.54厘米(约)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值