There are so many ways to get width and height.
1st Way
1st Way
Display
display = getWindowManager().getDefaultDisplay();
Point
size = new Point();
display.getSize(size);
int
width = size.x;
int
height = size.y;
2nd Way
Display
display = getWindowManager().getDefaultDisplay();
int
width = display.getWidth(); // deprecated
int
height = display.getHeight(); // deprecated
3rd Way
DisplayMetrics
metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
metrics.heightPixels;
metrics.widthPixels;
4th Way
int
width = getWindowManager().getDefaultDisplay().getWidth();
int
height = getWindowManager().getDefaultDisplay().getHeight();
No comments:
Post a Comment