zoukankan      html  css  js  c++  java
  • 获取android手机屏幕的宽高、density

    public static String getDisplayMetrics(Context cx) {
    String str = "";
    DisplayMetrics dm = new DisplayMetrics();
    dm = cx.getApplicationContext().getResources().getDisplayMetrics();
    int screenWidth = dm.widthPixels;
    int screenHeight = dm.heightPixels;
    float density = dm.density;
    float xdpi = dm.xdpi;
    float ydpi = dm.ydpi;
    str += "The absolute " + String.valueOf(screenWidth) + "pixels ";
    str += "The absolute heightin:" + String.valueOf(screenHeight)
    + "pixels ";
    str += "The logical density of the display.:" + String.valueOf(density)
    + " ";
    str += "X dimension :" + String.valueOf(xdpi) + "pixels per inch ";
    str += "Y dimension :" + String.valueOf(ydpi) + "pixels per inch ";
    return str;
    }
  • 相关阅读:
    解决sql2008附加不了2005的数据库文件的问题
    方阵
    台阶问题
    螺旋矩阵
    兔子问题
    九乘九乘法口诀
    选猴王
    拿鸡蛋问题
    软工个人作业
    小学四则运算法则训练
  • 原文地址:https://www.cnblogs.com/zhaoleigege/p/5689117.html
Copyright © 2011-2022 走看看