zoukankan      html  css  js  c++  java
  • 屏幕密度

    density 密度
    密度和dpi相关,dpi每英寸的点数

    densityDp
    {
    DENSITY_LOW = 120
    DENSITY_MEDIUM = 160 //默认值
    DENSITY_TV = 213 //TV专用
    DENSITY_HIGH = 240
    DENSITY_XHIGH = 320
    DENSITY_400 = 400
    DENSITY_XXHIGH = 480
    DENSITY_XXXHIGH = 640
    }

    private void getDensity() {
    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    Log.d(TAG,"Density is "+displayMetrics.density+" densityDpi is "+displayMetrics.densityDpi+" height: "+displayMetrics.heightPixels+
    " "+displayMetrics.widthPixels);
    }

    对角线的长度
    private void getScreenSizeOfDevice() {
    DisplayMetrics dm = getResources().getDisplayMetrics();
    int width=dm.widthPixels;
    int height=dm.heightPixels;
    double x = Math.pow(width,2);
    double y = Math.pow(height,2);
    double diagonal = Math.sqrt(x+y);

    int dens=dm.densityDpi;
    double screenInches = diagonal/(double)dens;
    Log.d(TAG,"The screenInches "+screenInches);
    }

  • 相关阅读:
    OkHttp的使用
    Adapter的实现
    RxJava的学习与实现
    Blueprint的实现
    The second group meeting!
    读书笔记1
    The First Team Meeting!
    java----使用NIO进行快速的文件拷贝
    java——类的学习(2)
    java——类的学习(1)
  • 原文地址:https://www.cnblogs.com/zhujiulunjian/p/6723256.html
Copyright © 2011-2022 走看看