Created
July 13, 2015 10:37
-
-
Save ninthdrug/1130f64f27c0df90c2fd to your computer and use it in GitHub Desktop.
android status bar height
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
DisplayMetrics displayMetrics = new DisplayMetrics(); | |
((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(displayMetrics); | |
int statusBarHeight; | |
switch (displayMetrics.densityDpi) { | |
case DisplayMetrics.DENSITY_HIGH: | |
statusBarHeight = HIGH_DPI_STATUS_BAR_HEIGHT; | |
break; | |
case DisplayMetrics.DENSITY_MEDIUM: | |
statusBarHeight = MEDIUM_DPI_STATUS_BAR_HEIGHT; | |
break; | |
case DisplayMetrics.DENSITY_LOW: | |
statusBarHeight = LOW_DPI_STATUS_BAR_HEIGHT; | |
break; | |
default: | |
statusBarHeight = MEDIUM_DPI_STATUS_BAR_HEIGHT; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment