11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

画面のインチ数を取得する

Posted at

タブレットの判定に。高解像度化が進んでピクセルではわからなくなったので。
7インチkindleは6.99という結果になったので6.5あたりが分かれ目かも。

private double getInch() {
    WindowManager windowManager = getWindowManager();
    Display display = windowManager.getDefaultDisplay();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    display.getMetrics(displayMetrics);
    double inchX = displayMetrics.widthPixels / displayMetrics.xdpi;
    double inchY = displayMetrics.heightPixels / displayMetrics.ydpi;
    double inch = Math.sqrt((inchX * inchX) + (inchY * inchY));
    Log.v("inch", inch + ":" + inchX + ":" + inchY);
    return inch;
}
11
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?