- <李>
强>设备独立像素),一个基于密度的抽象单位;
强>
李> <李>强>
>强的时候,用其他单位如dp会显得模糊;
强> 1 sp=1 dp=0.00625英寸,而当文字尺寸设置“大”或“超大”时,1 sp> 1 dp=0.00625英寸;
强>),常见取值120160240像素密度,简称密度;
强>
强>
强>
李>
,,,/* * ,,,,*,dp 的单位,转成为,px(像素) ,,,,*, ,,,,*,@param 上下文 ,,,,*,@param dpValue ,,,,* @return ,,,*/,,,public static int dip2px (Context 上下文,float dpValue), { ,,,,,,,final float scale =, context.getResources () .getDisplayMetrics () .density; ,,,,,,,return (int), (dpValue *, scale +, 0.5度); ,,,} ,,,/* * ,,,,*,从,px(像素),的单位,转成为,dp ,,,,*, ,,,,*,@param 上下文 ,,,,*,@param pxValue ,,,,* @return ,,,*/,,,public static int px2dip (Context 上下文,float pxValue), { ,,,,,,,final float scale =, context.getResources () .getDisplayMetrics () .density; ,,,,,,,return (int),(时间/pxValue scale +, 0.5度); ,,,}
,,,,,,在如下目录中分别对应各个分辨率的,即可做到不同手机的适配,,
,,,,
,,,,
,,,,,我是用下面的工具来看美工的图的,截图如下,可以切换不同的分辨率
,,,,