Get the right screen size on the Galaxy S8

In my application, I am currently using windowManager.getDefaultDisplay () to determine the screen size.

With the new Samsung S8 navigation bar, which can be shown and hidden with a “dot” in the lower left corner, I get the same display size for the displayed or hidden navigation bar. It always returns the size of the display, as if the navigation bar is being displayed - I expect to get 1080x2220 when the navigation bar is hidden, but always gets 1080x2076.

Is there any way to distinguish cases programmatically and get the correct screen sizes so that I can correctly display my application?

+5
source share
1 answer

I had the same problem as you and the solution I found was measuring the height of the root content . :

findViewById(android.R.id.content).getHeight() 

Hope this helps you.

here for more details about android.R.id.content

+1
source

Source: https://habr.com/ru/post/1271766/


All Articles