Reputation: 5033
I am trying to get the size of the screen. The size I have set for emulator is 540 x 960 but what I am getting is 320 x 480. Any suggestions on it to get the right size. Here is the code;
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
width = dm.widthPixels;
height = dm.heightPixels;
Upvotes: 2
Views: 2404
Reputation: 3220
try this one:
int height = getWindowManager().getDefaultDisplay().getHeight();
int width = getWindowManager().getDefaultDisplay().getWidth();
Upvotes: 1
Reputation: 22064
Try this:
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Upvotes: 7