首页 > 其他 > 详细

SparseArray,dip & px

时间:2014-09-23 13:29:25      阅读:279      评论:0      收藏:0      [点我收藏+]
  • SparseArray-用Array的方式实现Integer-Object的map
    • 优:节约内存,因为避免了装箱/拆箱,数据结构不依赖Entry
    • 劣:速度不及HashMap
  • dip、px
    • dip(device independent pixels)-设备独立像素,所有设备的数值都是 宽*高=320dip*480dip
    • px(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;
      }

       

SparseArray,dip & px

原文:http://www.cnblogs.com/maozhige/p/3986644.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!