get Status Bar Height from window top - Android android.app

Android examples for android.app:Status Bar

Description

get Status Bar Height from window top

Demo Code

import android.content.Context;
import android.graphics.Rect;
import android.view.View;

public class Main {

  public static int getStatusBarHeight(Context context) {
    Rect frameRect = new Rect();
    View view = new View(context);
    view.getWindowVisibleDisplayFrame(frameRect);
    return frameRect.top;
  }// w  w w .j  ava 2s  . com

}

Related Tutorials