Search code examples
androidandroid-studiodpi

Why does screen height of Nexus 5 doesn't feet to specs?


1) Create empty layout resource 2) Open it in Android Studio (2.2.2) 3) Set background colour 4) Set height as 550dp 5) set Nexus 5 as device for preview

You will see that layout has a tiny gap with the screen. So the actual height of layout is about 570dp Screen height = status bar height + the layout height = 24 + 570 = 594dp In specs Nexus 5 has 640dp

WTF?

enter image description here

Also it seems that I haven't toolbar. I added a view to relative layout with property of align parenttop and it was placed at the top right under status bar.

enter image description here


Solution

  • Count in the navigation bar's height which is 48dp according to this xml.

    <!-- Height of the bottom navigation / system bar. -->
    <dimen name="navigation_bar_height">48dp</dimen>
    <dimen name="navigation_bar_height_landscape">48dp</dimen>