December 26, 2016
How to Get Width and Height of Android Screen in Pixels
Sometimes you want to know the screen width and height in pixels. An example can be that you are developing a system information app and you have to display screen width and height in your activity. This is going to be so simple with very few lines of code. The following code snippet give you the screen width and height in pixels.
Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; Log.e("Width", "" + width); Log.e("height", "" + height);
Enjoy Coding and Share Knowledge