zoukankan      html  css  js  c++  java
  • 根据手机的分辨率从 dp 的单位 转成为 px(像素)

    /** * 根据手机的分辨率从 dp 的单位 转成为 px(像素) */ 
    public static int dip2px(Context context, float dpValue) {
       final float scale = context.getResources().getDisplayMetrics().density; 
       return (int) (dpValue * scale + 0.5f); 
    }
    ////////////////////////////////////////////
    
    
    public static int dip2px(Context context, float dpValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }
      
    public static int px2dip(Context context, float pxValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }
  • 相关阅读:
    linux系统缓存机制
    信号“未决”与“阻塞”
    异步I/O
    Unix下五种IO模型
    【设计模式
    【设计模式
    【设计模式
    【设计模式
    【设计模式
    【设计模式
  • 原文地址:https://www.cnblogs.com/wjhblogs/p/4304866.html
Copyright © 2011-2022 走看看