LoginSignup
5

More than 5 years have passed since last update.

Nexus7(2013)のスクリーンサイズのまとめ

Last updated at Posted at 2013-12-28

DisplayMetricsの値

onCreateにて、以下のメソッドを実行する。

    WindowManager windowManager = getWindowManager();
    Display display = windowManager.getDefaultDisplay();
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    Log.v("densityDpi", String.valueOf(metrics.densityDpi));
    Log.v("display", display.toString());

densityDpiの値

densityDpi = 320

metricsの値

DisplayMetrics {
  density=2.0, 
  width=1920,
  height=1104, 
  scaledDensity=2.0,
  xdpi=320.842, 
  ydpi=322.966
}

metricsの値

DisplayInfo {
  "内蔵スクリーン",
  app 1920 x 1104, 
  real 1920 x 1200, 
  largest app 1920 x 1774, 
  smallest app 1200 x 1054,
  60.0 fps,
  rotation1,
  density 320 (320.842 x 322.966) dpi,
  layerStack 0,
  type BUILT_IN, 
  address null, 
  FLAG_SECURE, 
  FLAG_SUPPORTS_PROTECTED_BUFFERS
},
DisplayMetrics {
  density=2.0,
  width=1920,
  height=1104, 
  scaledDensity=2.0,
  xdpi=320.842,
  ydpi=322.966
},
isValid=true

1920x1200の解像度を持っているが、ナビゲーションバーの高さが差し引かれて、1920x1104となるようだ。

ステータスバーの高さを取得

onWindowFocusChangedにて、以下のメソッドを実行する。

@Override
  public void onWindowFocusChanged(boolean focus) {
    super.onWindowFocusChanged(focus);
    Rect r = new Rect();
    getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
    Log.d("statusBar", "statusBar = " + r.top);
  }

statusBar = 50

さらにステータスバーの高さがあるので、Nexus7(2013)上のアプリで利用可能な画面サイズは、1920x1054となるようです。

Nexus7(2012)は1280x800なので、これをターゲットにした画像は、drawable-tvdpiにおいてやれば、伸張されます。drawable-tvdpiからdrawable-xhdpiへの伸張は、1.5倍(2/1.3333)と正しく扱われています。tvdpiは二次的密度でこれをターゲットにしてはいけないという記述がマニュアルにあります。正しい密度はxhdpiのようです。

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
5