Android & Wordpress Help center

How to get Height/Width of android screen?

The code snippet below helps you to determine the Height and Width of android screen:

Code before API 13

WindowManager wm = (WindowManager) .getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
this.width = display.getWidth();
this.height = display.getHeight();

Code for API 13+

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
int width = size.x;
int height = size.y;

This code will give you height of the window along with the status bar. If you want to exclude the height of status bar you can simply deduct it from the height of the entire window. Following code helps you determine the height of status bar:

Code to get height of status bar

public int getStatusBarHeight() {
int height = 0;
int resourceId = getResources().getIdentifier(“status_bar_height”, “dimen”, “android”);
if (resourceId > 0) {
height = getResources().getDimensionPixelSize(resourceId);

return height;


Single Post Navigation

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: