Reputation: 15392
I have a Samsung Galaxy S20+.
I run this code:
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
mScreenHeight = displayMetrics.heightPixels;
mScreenWidth = displayMetrics.widthPixels;
I get:
mScreenHeight = 2201.0 mScreenWidth = 1080.0
Whereas the S20+ screen resolution is 1440x3200 according to this page.
Such a big gap is not just a question of status bar height.
How can I get the real screen size in pixels ?
Thanks !
Upvotes: 1
Views: 1005
Reputation: 4978
Recent Galaxy S devices have a setting to change the screen resolution. On the S20+ there are 3 options:
You're likely in the FHD+ mode. Even though the device has a real pixel dimension of 3200x1440, your usable software window is downscaled and this is what the DisplayMetrics object is giving you.
Upvotes: 1