Created
March 16, 2017 06:48
-
-
Save vincent1086/169ad410de496dabfe475722a5b380c5 to your computer and use it in GitHub Desktop.
Android - get screen size
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
WindowManager wm = (WindowManager) textView.getContext().getSystemService(Context.WINDOW_SERVICE); | |
Display display = wm.getDefaultDisplay(); | |
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2){ | |
Point size = new Point(); | |
display.getSize(size); | |
deviceWidth = size.x; | |
} else { | |
deviceWidth = display.getWidth(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment