Reputation: 417
I need to get the exactly size screen but i cant get it.
I tried this two different codes:
DisplayMetrics display = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
height = display.heightPixels;
width = display.widthPixels;
Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
height = size.y;
width = size.x;
In both cases the height its correct (1080) but the width its not correct. It must return 1920 but its returning 1794. Its a Samsung Galaxy S4 (1920x1080). I have a full screen app, with no actionbar or navigation bar, etc. Why is happening this and how can ai get 1920. Im using API >= 14.
Greets
Upvotes: 3
Views: 2715
Reputation: 842
You can try with getRealSize instead of getSize (getRealSize)
Point size = new Point(); getWindowManager().getDefaultDisplay().getRealSize(size); height = size.y; width = size.x;
Upvotes: 2