Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Height of status bar in Android [duplicate]

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)

like image 370
hpique Avatar asked Aug 04 '10 15:08

hpique


People also ask

How do I increase the size of my status bar?

Select the gear icon to go to the system settings. Now go to the “Display” settings. Look for “Display Size” or “Screen Zoom.” Slide the dot on the scale at the bottom of the screen to adjust the size.


1 Answers

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; }  
like image 153
Jorgesys Avatar answered Sep 19 '22 20:09

Jorgesys