the height of the 1:decorview
The height of the Decorview represents the height of the entire decorative window, which includes: the height of the state rotten and the height of the navigation bar. (The status bar and navigation bar are often called decorative windows, while Actionbar is not part of the decoration window)
This height can represent the height of the entire glass screen.
height of the 2.Window rootview
Rootview access Method: GetWindow (). Findviewbyid (window.id_android_content);
This view corresponds to a height that can represent the current application's effective height.
In the absence of any modification, the height of the application is removed from the status bar and the navigation bar;
i.e. (height of the Decorview)-(height of the status bar)-(height of the navigation bar);
However, if you use:
Setsystemuivisibility (View.system_ui_flag_layout_fullscreen | View.system_ui_flag_hide_navigation);
This method, then the height of the rootview will be equal to the height of the Decorview;
the height of the 3:heightpixels
Heightpixels
This height means ... The height of the screen is effective;;;
What do you mean?
is: the height of the Decorview removes the height of the navigation bar.
This height no matter whether you have hidden the navigation bar, this value will not change;
So:
pan out: If you want to know if your phone has a navigation bar:
if (decorview height)-(heightpixels) > 0 Description Your phone has a navigation bar
pan out: If you want to know if your program has hidden navigation bar:
Scenario 1: Set the System_ui_flag_layout_fullscreen property:
if (rootview height)-(heightpixels) > 0 Description shows the navigation bar
Scenario 2: The System_ui_flag_layout_fullscreen property is not set:
if (rootview height + status bar height)-(heightpixels) > 0 Description Show navigation bar
Additional 1 Gets the height of the status bar
Under normal conditions: (heightpixels)-(height of rootview) = height of the status bar
But if you set the View.system_ui_flag_layout_fullscreen or View.system_ui_flag_hide_navigation attribute,,, this method is inaccurate.
Magnum, 100% Accurate method:
Getresources (). Getdimensionpixelsize (Getresources (). Getidentifier ("Status_bar_height", "Dimen", "Android"));
Add 2: Get the height of the navigation bar
Normal: (height of Decorview)-(heightpixels) = height of navigation bar
But if you set the View.system_ui_flag_hide_navigation attribute,,, this method is inaccurate.
Magnum, 100% Accurate method:
Getresources (). Getdimensionpixelsize (Getresources (). Getidentifier ("Navigation_bar_height", "Dimen", "Android"));
Android--> status bar height, navigation bar height, window height, decorview height, heightpixels