Historically, programmers always designed computer interfaces in terms of pixels. For example, you mightmake a field 300 pixels wide, allow 5 pixels of spacing between columns, and define icons 16-by-16 pixels in size. The problem is that if you run that program on new displays with more and more dots per inch (dpi), the user interface appears smaller and smaller. At some point, it becomes too hard to read. Resolution-independent measurements help solve this problem.
Android supports all the following units:
• px (pixels): Dots on the screen.
• in (inches): Size as measured by a ruler.
• mm (millimeters): Size as measured by a ruler.
• pt (points): 1/72 of an inch.
• dp (density-independent pixels): An abstract unit based on the density of the screen. On a display with 160 dots per inch, 1dp = 1px.
• dip: Synonym for dp, used more often in Google examples.
• sp (scale-independent pixels): Similar to dp but also scaled by the user’s font size preference.
To make your interface scalable to any current and future type of display, I recommend you always use the sp unit for text sizes and the dip unit for everything else. You should also consider using vector graphics instead of bitmaps
dip就是dp
dip是密度不相关像素。为了适应有的屏幕大有的屏幕小。为了达到统一的显示效果。
sp是字体推荐使用的,也会适应手机的字体大小
作为图片最好使用的是矢量图,9.png。而不要使用位图。
分享到:
相关推荐
NULL 博文链接:https://1307111376.iteye.com/blog/1986752
描述android的dip dp px dp等单位及其转换关系
Android中显示单位px和dip以及sp的区别
简单的比较android各个单位的小程序
dip dp px sp区别 dip dp px sp区别 dip dp px sp区别
Android的计量单位px,in,mm,pt,dp,dip,sp Android的计量单位px,in,mm,pt,dp,dip,sp
本篇文章是对Android中dip、dp、sp、pt和px的区别进行了详细的分析介绍,需要的朋友参考下
<Button android:layout_width="135dip" android:textSize="18sp" android:layout_height="45dip" android:text="确定" android:id="@+id/btnOk"/> </LinearLayout> android自定义弹出框,很实用的
在屏幕密度为160的显示屏上,1dip=1px,有时候可能你的屏幕分辨率很大如480*800,但是屏幕密度没有正确设置比如说还是160,那么这个时候凡是使用dip的都会显示异常,基本都是显示过小。 dip的换算: dip(value)=...
Android开发中的常用尺寸单位有如下几种: dp (dip) px pt inch sp 算不知道确切含义,相信对于以上这几种尺寸单位大家也都比较脸熟,这里先让我们重新认识一下它们: dp (dip): 即设备无关像素(device ...
从一开始写Android程序,就被告知这些常识 一、dp(或者dip device independent pixels... 字体大小的数值要使用sp作为单位,也放入dimens.xml文件中 然后,就没有然后了,仿佛潜台词就是说,你记住去用就行了. 偶然有一天,
本篇文章是对Android中dip,px,pt,sp的区别进行了详细的分析介绍,需要的朋友参考下
此属性在EditView中使用,但是这里也可以用。 android:imeOptions附加功能,设置右下角IME动作与编辑框相关的动作,如actionDone右下角将显示一个“完成”,而不设置默认是一个回车符号。这个在EditView中再详细...
android sp dp px dip pt in mm 等单位
3.1 sp、dp、dip、pt、px等单位的区别 17 3.2 TextView属性 18 3.3跑马灯效果的最小代码集 19 3.4给按钮注册点击事件的方式 19 3.5 EditText属性 20 3.6 simple_list_item_1是什么 21 3.7 ImageView的属性 22 3.8 ...
android:textSize="15sp" /> </LinearLayout>Activity:ShadowViewHelper.bindShadowHelper( new ShadowProperty() .setShadowColor(0x77000000) .setShadowDy(ABTextUtil.dip2px(context, 0.5f)) ....