By default, the height of the statusbar is 25dip, this value will not change, whether your screen is 240*320 or 600*800 or other resolutions, StatusBar height is 25dip.
Perhaps some students will say, how could it be, the value of 600*800 equipment on the statusbar height is obviously much higher!
Yes, the value of 600*800 such a device, the height of StatusBar looks really much higher than the 240*320 screen, but it is indeed 25dip, but at this time it is not 25px.
On the device of 240*320 resolution, 25DIP, when displayed on the device, its length or height is 25 pixels, that is 25px, but on the 600*800 device, this 25dip is no longer 25px.
Let's teach you how to get this height on different devices. It's actually very simple:
Displaymetrics metrics = getresources (). Getdisplaymetrics ();
int status_bar_height = (int) Math.ceil (+ * metrics.density);
In fact, all we have to do is convert this 25dip height to px, because the height we need in the code is in PX.
How to get the height of StatusBar (Android platform)