SparseArray,dip & px

it2022-05-09  55

SparseArray-用Array的方式实现Integer-Object的map 优:节约内存,因为避免了装箱/拆箱,数据结构不依赖Entry劣:速度不及HashMapdip、px dip(device independent pixels)-设备独立像素,所有设备的数值都是 宽*高=320dip*480dippx(pixels)-像素,设备实际像素,同样尺寸,越精细的屏幕数值越大 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().density;   return (int) pxValue / scale + 0.5f; }

 

转载于:https://www.cnblogs.com/maozhige/p/3986644.html


最新回复(0)