【问题标题】:How I can get the current size screen through of programming? [duplicate]如何通过编程获得当前大小的屏幕? [复制]
【发布时间】:2013-11-12 19:31:40
【问题描述】:

我想在 Android 上获取当前尺寸的屏幕英寸以选择适合每个屏幕的图像,因为我的 imageview 当前在某些屏幕上更大!有什么方法可以得到吗?

【问题讨论】:

    标签: android imageview


    【解决方案1】:

    看看这个:

    Is there a way to determine android physical screen height in cm or inches?

        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        double x = Math.pow(dm.widthPixels/dm.xdpi,2);
        double y = Math.pow(dm.heightPixels/dm.ydpi,2);
        double screenInches = Math.sqrt(x+y);
        Log.d("debug","Screen inches : " + screenInches);
    

    【讨论】:

    • 不应复制现有答案,而应将问题标记为重复
    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-20
      • 2010-12-28
      • 1970-01-01
      • 1970-01-01
      • 2013-04-17
      • 1970-01-01
      • 2013-06-04
      相关资源
      最近更新 更多