A dimension value defined in XML. A dimension is specified with a number followed by a unit of measure. For example: 10px, 2in, 5sp. The following units of measure are supported by Android:
Android系统中,度量单位dimension是在XML文件中定义的。一个度量一般由一个具体的数值和对应的单位指定(以下介绍的dp、sp、pt等)。
dp
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi (dots per inch) screen, so160dp
is always one inchregardless
of the screen density. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. You should use these units when specifying view dimensions in your layout, so the UI properly scales to render at the same actual
size on different screens. (The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".)
在android系统中单位DP也就是DIP:device independent pixels(设备独立像素)。
dip: device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA、HVGA和QVGA
推荐使用这个,不依赖像素。
sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and the user's preference.
缩放独立像素,主要用于字体。能根据用户设定的字体大小数值和屏幕的密度来调整显示大小。
pt
Points - 1/72 of an inch based on the physical size of the screen.
是一个标准的长度单位,1pt=1/72英寸。
px
Pixels - corresponds to actual pixels on the screen. This unit of measure is not recommended because the actual representation can vary across devices; each devices may have a different number of pixels per inch and may have more or fewer total pixels available
on the screen.
对应于屏幕实际的像素。因为不同的设备有不同的分辨率,即一英寸里面包含不同数目的像素点,所以同样的数值在不同的手机屏幕上有不同的表现,不推荐使用。
mm
Millimeters - based on the physical size of the screen.
in
Inches - based on the physical size of the screen.
总结:dp也就是dip。这个和sp基本类似。如果设置表示长度、高度等属性时可以使用dp或sp。但如果设置字体,需要使用sp。dp是与密度无关,sp除了与密度无关外,还与scale无关。如果屏幕密度为160,这时dp和sp和px是一样的。1dp=1sp=1px,但如果使用px作单位,如果屏幕大小不变(假设还是3.2寸),而屏幕密度变成了320。那么原来TextView的宽度设成160px,在密度为320的3.2寸屏幕里看要比在密度为160的3.2寸屏幕上看短了一半。但如果设置成160dp或160sp的话。系统会自动将width属性值设置成320px的。也就是160
* 320 / 160。其中320 / 160可称为密度比例因子。也就是说,如果使用dp和sp,系统会根据屏幕密度的变化自动进行转换.
分享到:
相关推荐
We give a tutorial overview of several geometric methods for dimension reduction. We divide the methods into projective methods and methods that model the manifold on which the data lies. For ...
Rather, Imagining the Tenth Dimension is a mind-expanding exercise that could change the way you view this incredible universe in which we live. Read the book whose companion website (tenthdimension...
Data Quality: The Accuracy Dimension is about assessing the quality of corporate data and improving its accuracy using the data profiling method. Corporate data is increasingly important as companies ...
分形维度指数(Fractal Dimension Index)指标体现了市场动荡的程度.
Two Dimension Signal and image processing MIT Textbook 麻省理工教材
Matlab 计算曲线的分型维数fractal dimension,FD
Ising model (2-dimension) fortran code
dimension-2400_owner's manual中文版,老电脑的资料
在新建的FORM上使用系统的Dimension display功能
Three_dimensiona ThreadConnection,基于ANSYS分析得出的三维分析
Dimension Reduction A Guided Tour give a tutorial overview of several foundational methods for dimension reduction. We divide the methods into projective methods and methods that model the manifold on...
Ising model (1-dimension) fortran code Ising modelIsing model
Business Objects Merge Dimension
PDAL-Dimension.cpp c++ pdal lidar library
在MATLAB上所使用的PCA程序,主要應用於過濾相對較不重要的特徵值(dimension),例如在三度空間的某些點具有(x,y,z)值,因為這些點有共同的一個持徵,就是z值相對於x,y值來得小很多(不明顯),所以就以X,Y軸來表示這些...
計算embedding dimension. 可檢測時間序列之embedm, fnn1, fnn2三數值
English version, cover some InfoCube modeling best practices like M:N relationship of Master data, one or two dimensions, partitioning
一篇关于使用QR分解降维的文章,探索了对降维过程中保持不变的属性
签出传单TimeDimension演示。 基本用法: < html > < head > < title > Leaflet TimeDimension Demo </ title > < link rel =" stylesheet " href =" ...