Q: Height of status bar in Android

D: What's the height of the status bar in Android? Is it always the same? From my measurements it seems that it's 25dp, but I'm not sure if it has the same height on all platforms. (I want to know this to properly implement a fade transition from an activity that doesn't have status bar to one that does)

Test Case #12


File ID: #3410200-2-cc


   
   public static int getStatusBarHeight(Context context) {
    int result = 0;
    int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        result = context.getResources().getDimensionPixelSize(resourceId);
    }
    return result;
}

  1. Didn't work in onCreate
  2. Or use dip? If it always has 25dip then the code is not needed.
  3. you can't assume it's always 25dp (check out the height for example on the kindle fire).

Comments Quality
Accurate?:
Precise?:
Concise?:
Useful?: