Reputation: 1765
I am trying to get the width and height of the screen in Android, i have:
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
stageWidth = displaymetrics.widthPixels;
stageHeight = displaymetrics.heightPixels;
The width is 1280 but its coming back with 752.
Any ideas?
Upvotes: 2
Views: 7050
Reputation: 1
Rotate your screen and see.I think you will get your correct screen size.
The above code worked with me and should work with you.
Upvotes: 0
Reputation: 555
Use this method on the display object (from the docs):
void getSize(Point outSize) -
Returns the raw size of the display, in pixels.
Upvotes: 0
Reputation: 2199
Try this instead:
Display display = getWindowManager().getDefaultDisplay();
stageWidth = display.getWidth();
stageHeight = display.getHeigth();
Is that the same width? Are you sure the width is 1280 and not 752? What device are you testing it on and what height are you getting?
Upvotes: 4