Pages

Saturday, February 15, 2014

How to get screen dimensions in android



There is Display class to get the display of screen in android.

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
//getSize()  method is introduced in API level 13.
int width = size.x;
int height = size.y;

Before API  level 13 below method are used.

Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth(); //this method is deprecated now
int height = display.getHeight();//this method is deprecated now



No comments:

Post a Comment