Created
July 23, 2014 15:57
-
-
Save asiletto/26f97784a4012ec8d605 to your computer and use it in GitHub Desktop.
Get width height and orientation in android
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
Display display = getWindowManager().getDefaultDisplay(); | |
DisplayMetrics outMetrics = new DisplayMetrics(); | |
display.getMetrics(outMetrics); | |
float density = getResources().getDisplayMetrics().density; | |
float dpHeight = outMetrics.heightPixels / density; | |
float dpWidth = outMetrics.widthPixels / density; | |
Log.d("SIZE","height: "+dpHeight+"dp, width:"+dpWidth+"dp, orientation:"+display.getRotation()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment