0

So i know how to get the screen size of an android device.

But how do i get the the size of the notification bar which comes in the top?

   DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    height = displaymetrics.heightPixels;
    width = displaymetrics.widthPixels;
Wishy
  • 391
  • 2
  • 6
  • 18
  • http://stackoverflow.com/questions/3600713/size-of-android-notification-bar-and-title-bar – Sam Jun 04 '13 at 04:44

1 Answers1

1

This question was already answered : Height of status bar in Android

But you can do this like this :

Rect rectgle= new Rect();
Window window= getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
int StatusBarHeight= rectgle.top;
int contentViewTop= 
    window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int TitleBarHeight= contentViewTop - StatusBarHeight;

   Log.i("*** Jorgesys :: ", "StatusBar Height= " + StatusBarHeight + " , TitleBar Height = " + TitleBarHeight); 
Community
  • 1
  • 1
Vipul Purohit
  • 9,807
  • 6
  • 53
  • 76