Monday, June 13, 2011

How to get the size and orientation of your device screen

Found this great snippet over at that allows you to find the size and orientation of the device screen at runtime, and thought I'd share it:

/* First, get the Display from the WindowManager */
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();

/* Now we can retrieve all display-related infos */
int width = display.getWidth();
int height = display.getHeight();
int orientation = display.getOrientation();
// see

1 comment:

  1. Awesome snippet and awesome web, thanks for linking to it!