code: public static int getStatusBarHeight(Context ctx) {
          int result = 0;
          int resourceId = ctx.getResources().getIdentifier("status_bar_height", "dimen", "android");
          if (resourceId > 0) {
              result = ctx.getResources().getDimensionPixelSize(resourceId);
          }
          return result;
      }
docs: Get the status bar height