Get the Height of the Status Bar in Android
Sometimes in Android, the flexible layout system is not flexible enough and you need to make some computations inside your code. In these computations, you may need to subtract the size of the status bar. Stackoverflow gives you some answers, but they all rely on the fact that te status bar is shown at the time you make your computation. If you are in full screen mode, by having called for instance:
It doesn’t work.
The height of the status bar is contained in a dimension resource called
status_bar_height. It’s not part of the public resources, so you can’t access
it directly from your code with
android.R.dimen.status_bar_height. You can
however compute it at runtime with the following code:
You need to put this method in a
Hope it helps.