Created
April 20, 2015 11:10
-
-
Save hamakn/bab12c4348b1d95bffa9 to your computer and use it in GitHub Desktop.
DisplayMetrics#widthPixels の値が機種とデバイスの向きによって変わる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# screen orientationは固定 | |
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | |
DisplayMetrics metrics = new DisplayMetrics(); | |
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); | |
Log.d("metrics.widthPixels: " + metrics.widthPixels); | |
# SONY SO-02g Android 4.4.4 | |
# => デバイスが縦向きでも横向きでも metrics.widthPixels の値は同じ | |
# Samsung SC-02f Android 4.4.2 | |
# => デバイスが縦向きか横向きかで metrics.widthPixels の値が変わる(Heightと入れ替わる) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment