Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Screen size full screen

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

like image 681
user3240604 Avatar asked Aug 22 '26 00:08

user3240604


1 Answers

You can try with getRealSize instead of getSize (getRealSize)

Point size = new Point();
getWindowManager().getDefaultDisplay().getRealSize(size);
height = size.y;
width = size.x;
like image 61
toidv Avatar answered Aug 24 '26 13:08

toidv