pixels
共 2 篇文章
dpi 与 px 的互相转换
public static int dip2px(Context context, float dipValue){ final float scale = context.getResources().getDisplayMetrics().density; return (int)(dipValue * scale + 0.5f); } public static int px2dip(Context context, float pxValue){ final float scale = context.getResources().getDisplayMetrics().densit…
Android 机使用的像素比列!
Android 密度 DisplayMetrics 提供三种 密度 DENSITY_LOW 最小 密度 对应 文件夹 ldpi 是 120 DENSITY_MEDIUM 适中 密度 对应 文件夹 mdpi是160 DENSITY_HIGH 最大 密度 对应 文件夹 hdpi是240 xhdpi是320 (在Android 2.2 源码中未找到该属性) 默认 密度为 DENSITY_MEDIUM 设图标原尺寸为 x,y.图标取出文件夹时的尺寸为,Rx,Ry. 具体公式是: density 驱动的密度 Rx = x * (density/ density(文件夹对应的dpi)) Ry = y *…