Created
June 23, 2016 06:35
-
-
Save ksu3101/15a6e46d715679734e78a446763b2ffb to your computer and use it in GitHub Desktop.
안드로이드 상단 status bar의 높이를 얻는 메소드
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* StatusBar의 높이를 얻는다. | |
* | |
* @param context Context instance | |
* @return pixel size of Statusbar height or 0 | |
*/ | |
public static int getStatusBarHeight(Context context) { | |
if (context != null) { | |
int statusBarHeightResourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); | |
if (statusBarHeightResourceId > 0) { | |
return context.getResources().getDimensionPixelSize(statusBarHeightResourceId); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment