Skip to content

Instantly share code, notes, and snippets.

@ksu3101
Created June 23, 2016 06:35
Show Gist options
  • Save ksu3101/15a6e46d715679734e78a446763b2ffb to your computer and use it in GitHub Desktop.
Save ksu3101/15a6e46d715679734e78a446763b2ffb to your computer and use it in GitHub Desktop.
안드로이드 상단 status bar의 높이를 얻는 메소드
/**
* 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