Height of status bar in Android

change status bar height android
android status bar png
android status bar height react-native
android app bar height
android get toolbar height programmatically
hide status bar android
transparent status bar android
status bar height ios

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)

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


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();
int statusBarHeight = rectangle.top;
int contentViewTop = 
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;

iOS Design Cheat Sheet, action bar height. int actionBarHeight = 0;. final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(. new int[] { android.R.attr. This example demonstrates how to height of the status bar in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml.

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/

How to Hide Icons in Android's Status Bar, iPhone 4-inch iPhone 5, iPhone 5S, iPhone 5C, iPhone SE But on 10" tablet (which I don't see status bar anywhere on screen), the statusBarHeight snippet return 50px. Which cause the displayableHeight 50px less than what user see on the screen. Do you know why on 10" Tablet report status bar height = 50px since is not showing on screen and How can I fix this issue? Best

On MDPI devices, the status bar is 25px. We can use this as the base and multiply it by the density (rounded up) to get the status bar height on any device:

int statusBarHeight = Math.ceil(25 * context.getResources().getDisplayMetrics().density);

For reference: ldpi=.75, mdpi=1, hdpi=1.5, xhdpi=2

How to find height of status bar in Android through React Native , iPad Retina iPad 3, 4, 5, 6, 7, Air 1, Air 2, Air 3, Pro, Mini 2, 3, 4, 5 Android: Get height of status, action, navigation bar (pixels) - height.java

Hardcoding the size or using reflection to get the value of status_bar_height is considered bad practice. Chris Banes talked about this in at the Droidcon New York. The recommended way of getting the status bar size is via the OnApplyWindowInsetsListener:

myView.setOnApplyWindowInsetsListener { view, insets -> {
  val statusBarSize = insets.systemWindowInsetTop
  return insets

This was added in API 20 and is also backported via ViewAppCompat.

Android - most top bar name?, icons: Wi-Fi, Bluetooth, mobile network, battery, time, alarm, etc. How to get the height of the navigation bar and status bar. This code works for me on some Huawei devices and Samsung devices. Egis's solution above is good, however, it is still incorrect on some devices. So, I improved it. This is code to get the height of status bar

I've merged some solutions together:

public static int getStatusBarHeight(final Context context) {
    final Resources resources = context.getResources();
    final int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0)
        return resources.getDimensionPixelSize(resourceId);
        return (int) Math.ceil((VERSION.SDK_INT >= VERSION_CODES.M ? 24 : 25) * resources.getDisplayMetrics().density);

another alternative:

    final View view = findViewById(android.R.id.content);
    runJustBeforeBeingDrawn(view, new Runnable() {
        public void run() {
            int statusBarHeight = getResources().getDisplayMetrics().heightPixels - view.getMeasuredHeight();

EDIT: Alternative to runJustBeforeBeingDrawn: https://stackoverflow.com/a/28136027/878126

How do I get the status bar height in react native? You can hide the status bar on Android 4.1 (API level 16) and higher by using setSystemUiVisibility(). setSystemUiVisibility() sets UI flags at the individual view level; these settings are aggregated to the window level.

What is the bar at the top of the phone called? On that screen, tap Material Status Bar. It will double-check to make sure you want to grant Material Status Bar that permission. Tap OK. Next, use your back button to return to the Material Status Bar app and select Notifications. Toggle on the switch in the upper right and then tap allow.

Test in a simulator with (⌘ Y) to toggle the status bar height. #9 Support android Opened by n-sviridenko over 1 year ago #10 Does not support orientation  xda-developers Android Development and Hacking Android Q&A, Help & Troubleshooting [Q] Can anyone change the height of status bar? by frankie_meng XDA Developers was founded by developers, for developers.

This example demonstrates how to height of the status bar in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project  Get Status Bar Height in Flutter Android iOS App Example Tutorial admin September 26, 2019 September 26, 2019 Flutter Tutorials Status bar is a horizontal graphical bar present at top of mobile application screen.

  • If you do a cross fade then you wont need to know the height of status bar.
  • I do need it because some elements are centered in the layout, and I would to have them fade into each other.
  • possible duplicate of Height of statusbar?
  • Not exactly. I'm also asking if I can assume that the status bar has the same height in all devices.
  • Or use dip? If it always has 25dip then the code is not needed.
  • you can't assume it's always 25dp (check out the height for example on the kindle fire).
  • Doesn't work in runnable passed to view.post() in onCreate() - return 0
  • window.getDecorView().getWindowVisibleDisplayFrame(rectangle) is not a correct way to get status bar height if you are in multi-window mode + portrait rotation + second window. You will get a huge value (include the 1st height).
  • Instead of hard coding it, better to calculate dynamically. The above method worked for me!
  • shouldn't you use getDimension(...) instead ?
  • A word of caution - this does not work on all devices. E.g. on Transformer TF201 (as well as TF101, TF300 and some other devices) the height is reported as 25 where there is no status bar.