this question was answered before... Height of statusbar?

Update::

Current method:

ok, the height of the status bar depends on the screen size, for example in a device with 240 X 320 screen size the status bar height is 20px, for a device with 320 X 480 screen size the status bar height is 25px, for a device with 480 x 800 the status bar height must be 38px

so i recommend to use this script to get the status bar height

Rect rectangle = new Rect();
Window window = getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
int statusBarHeight = rectangle.top;
int contentViewTop = 
    window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int titleBarHeight= contentViewTop - statusBarHeight;

   Log.i("*** Elenasys :: ", "StatusBar Height= " + statusBarHeight + " , TitleBar Height = " + titleBarHeight); 

(old Method) to get the Height of the status bar on the onCreate() method of your Activity, use this method:

public int getStatusBarHeight() { 
      int result = 0;
      int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
      if (resourceId > 0) {
          result = getResources().getDimensionPixelSize(resourceId);
      } 
      return result;
} 
Answer from Jorgesys on Stack Overflow
Top answer
1 of 16
400

this question was answered before... Height of statusbar?

Update::

Current method:

ok, the height of the status bar depends on the screen size, for example in a device with 240 X 320 screen size the status bar height is 20px, for a device with 320 X 480 screen size the status bar height is 25px, for a device with 480 x 800 the status bar height must be 38px

so i recommend to use this script to get the status bar height

Rect rectangle = new Rect();
Window window = getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
int statusBarHeight = rectangle.top;
int contentViewTop = 
    window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int titleBarHeight= contentViewTop - statusBarHeight;

   Log.i("*** Elenasys :: ", "StatusBar Height= " + statusBarHeight + " , TitleBar Height = " + titleBarHeight); 

(old Method) to get the Height of the status bar on the onCreate() method of your Activity, use this method:

public int getStatusBarHeight() { 
      int result = 0;
      int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
      if (resourceId > 0) {
          result = getResources().getDimensionPixelSize(resourceId);
      } 
      return result;
} 
2 of 16
235

Out of all the code samples I've used to get the height of the status bar, the only one that actually appears to work in the onCreate method of an Activity is this:

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

Apparently the actual height of the status bar is kept as an Android resource. The above code can be added to a ContextWrapper class (e.g. an Activity).

Found at http://mrtn.me/blog/2012/03/17/get-the-height-of-the-status-bar-in-android/

🌐
Reddit
reddit.com › r/figmadesign › android status bar height
r/FigmaDesign on Reddit: Android status bar height
April 3, 2023 -

According to android documentations, the height of status bar is almost always 24dp. With this in mind, what should the height of the status bar be in Figma Android small (360x640) and Android Large (360x800)?

I guess they should be the same height, but I don't know the height. I have tried to match a screenshot and I got something around 21.59! But I have seen people put it in different sizes in Figma designs. Also, I asked this from ChatGPT and it said it should probably be 24px :)

Discussions

Height of Android navigation bar (solved) - Audio and Graphics - Solar2D Game Engine
For months there were so many discussions on how to define Android navigation bar height. I finally found how to get it. There are so many “helpful-unhelpful” links that the only solution was to hide the bar at all and stop bothering yourself about the height. As for the top status bar, then ... More on forums.solar2d.com
🌐 forums.solar2d.com
6
0
January 28, 2021
Get the height of the statusBar of Android
So may I ask, how did you make ... status bar. All I manage is either a black background behind the Statusbar(app doesn't reach that far up), or the App is painted over the Statusbar all together. How does it behave, when you force a notch/cutout from the developer settings · Not sure what is this mean, if you mean the statusBarHeight function, it works very well. I actually meant this setting: https://developer.android.com/guide... More on forum.qt.io
🌐 forum.qt.io
4
0
August 1, 2019
Does anyone know if there's a way change the status bar height
No way in a regular stock rom. You can only do it in custom rom. More on reddit.com
🌐 r/oneui
14
13
September 8, 2024
android - Get status bar height dynamically from XML - Stack Overflow
I need to optimize my Android app to look good on phones with a notch, like the Essential Phone. This phones have different status bar heights than the standard 25dp value, so you can't hardcode t... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Medium
medium.com › javarevisited › how-to-get-status-bar-height-in-android-programmatically-c127ad4f8a5d
How To Get Status Bar Height In Android Programmatically ? | by Mouad Oumous | Javarevisited | Medium
March 11, 2024 - But hey, no worries! We’ve got the lowdown on how to nail that status bar height like a pro. Picture this: you’re designing your dream app, and then bam! The status bar throws a curveball by changing its height on different devices. It’s like playing Whack-a-Mole, but with pixels!
🌐
React Native
reactnative.dev › docs › statusbar
StatusBar · React Native
2 weeks ago - The height of the status bar, which includes the notch height, if present. If the transition between status bar property changes should be animated. Supported for backgroundColor, barStyle and hidden properties. The background color of the status bar. ... Due to edge-to-edge enforcement introduced in Android ...
🌐
Material Design
m2.material.io › design › platform-guidance › android-bars.html
Android bars
Build beautiful, usable products faster. Material Design is an adaptable system—backed by open-source code—that helps teams build high quality digital experiences.
🌐
Android Developers
developer.android.com › ui design › mobile › android system bars
Android system bars | Mobile | Android Developers
November 7, 2025 - Include system bars in your layouts for different screen sizes and form factors. Account for UI safe zones, system interactions, input methods, display cutouts, status bars, caption bars, navigation bars, and other device capabilities.
🌐
Google Groups
groups.google.com › g › android-porting › c › 3WL1b4GYm2w
Increasing the size of status bar
Make sure you also change status_bar_height in dimens.xml: <!-- Height of the status bar --> <dimen name="status_bar_height">25dip</dimen> ... -- unsubscribe: [email protected] website: http://groups.google.com/group/android-porting -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.
Find elsewhere
🌐
Solar2D
forums.solar2d.com › audio and graphics
Height of Android navigation bar (solved) - Audio and Graphics - Solar2D Game Engine
January 28, 2021 - For months there were so many discussions on how to define Android navigation bar height. I finally found how to get it. There are so many “helpful-unhelpful” links that the only solution was to hide the bar at all and stop bothering yourself about the height. As for the top status bar, then ...
🌐
Qt Forum
forum.qt.io › home › qt development › mobile and embedded › get the height of the statusbar of android
Get the height of the statusBar of Android | Qt Forum
August 1, 2019 - Rect rectangle = new Rect(); Window window = getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rectangle); int statusBarHeight = rectangle.top; int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop(); int titleBarHeight= contentViewTop - statusBarHeight;
🌐
Android Developers
developer.android.com › core areas › ui › views › display content edge-to-edge in views
Display content edge-to-edge in views | Views | Android Developers
Many apps have a top app bar. The top app bar should stretch to the top edge of the screen and display behind the status bar. Optionally, the top app bar can shrink to the height of the status bar when the content scrolls.
🌐
XDA Forums
xdaforums.com › home › google › google pixel 9 pro / 9 pro xl
Question - Easy way to adjust status bar height? | XDA Forums
January 31, 2025 - the easiest way to change that nasty google nonsense with statusbar, "pixelxpert" only available on stock google rom for no reason and "iconify" works everywhere but has less quirks and features.
🌐
XDA Forums
xdaforums.com › home › general development › android development and hacking › android q&a, help & troubleshooting
How to change status bar height? | XDA Forums
November 26, 2017 - I've got an Essential Phone (7.1.1, Magisk + Xposed) and I'm trying to to change the status bar height. Here's a stock image of what it looks like at default dpi. I was able to use use the window manager (adb shell wm) to offset the status bar...
🌐
GitHub
gist.github.com › hamakn › 8939eb68a920a6d7a498
Android: Get height of status, action, navigation bar (pixels) · GitHub
JNI translation for getting status bar height: (tested with a NativeActivity app) static int AndroidStatusBarShown(int* height = NULL) { JNIEnv* jni; g_App->activity->vm->AttachCurrentThread(&jni, NULL); bool state = false; jclass cls = jni->GetObjectClass(g_App->activity->clazz); jmethodID getResourcesMID = jni->GetMethodID(cls, "getResources", "()Landroid/content/res/Resources;"); jobject resources = jni->CallObjectMethod(g_App->activity->clazz, getResourcesMID); jclass resources_cls = jni->GetObjectClass(resources); jmethodID getIDMID = jni->GetMethodID(resources_cls, "getIdentifier", "(Lja
🌐
TutorialsPoint
tutorialspoint.com › what-is-the-height-of-the-status-bar-in-android
What is the height of the status bar in Android?
November 15, 2019 - package com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.content.res.Resources; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getStatusBarHeight(); } private int getStatusBarHeight() { int height; Resources myResources = getResources(); int idStatusBarHeight = myResources.getIdentifier( "status_bar_height", "dimen", "android"); if (idStatusBarHeight > 0) { height = getResources().getDimensionPixelSize(idStatusBarHeight); Toast.makeText(this, "Status Bar Height = " + height, Toast.LENGTH_LONG).show(); } else { height = 0; Toast.makeText(this, "Resources NOT found", Toast.LENGTH_LONG).show(); } return height; } }
🌐
GitHub
github.com › facebook › react-native › issues › 33612
`StatusBar.currentHeight` gives incorrect height on Google Pixel 5a (Android 12) · Issue #33612 · facebook/react-native
January 20, 2022 - Screenshot when using StatusBar.currentHeight as the top margin ... example on Expo, this is occurring in multiple versions of react native, notably tested on 0.66.0 and 0.64.2 ... compare calculated height on Google Pixel 5a (Android 12) to other Android devices - the height for Pixel 5a Android 12 does not match the full height as it appears on the device while other devices do still work
Published   Apr 11, 2022
🌐
Android Central
forums.androidcentral.com › home › samsung android phones › samsung galaxy s21 & s21+ & s21 ultra
How to enlarge statusbar? | Android Central Forum
April 8, 2021 - I tried screen zoom and fonts size to enlarge the icons and clock of the status bar but no joy It's a pity to see 6.8'' of screen but such a tiny space for...
🌐
Solar2D
forums.solar2d.com › other
Status bar height issue - Other - Solar2D Game Engine
November 5, 2012 - Jeremy, It’s definitely a bug in your code. It’s caused by your usage of the “display.screenOriginY” property which provides the y component of the top-left coordinate of the screen in “content coordinates”. Since your app is set up to be letterboxed, this property will provide a negative y value if a letterbox bar is shown at the top of the screen… which will be the case for the vast majority of Android devices.