Created
May 4, 2020 16:26
-
-
Save Suchiq/2ef2d0d655ed21196c614c64e34adb3e to your computer and use it in GitHub Desktop.
Calculate 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
public static int getStatusBarHeight() { | |
int statusBarHeight = 0; | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
int resourceId = getContext().getResources() | |
.getIdentifier("status_bar_height", "dimen", "android"); | |
if (resourceId > 0) { | |
statusBarHeight = getContext().getResources() | |
.getDimensionPixelSize(resourceId); | |
} | |
} | |
return statusBarHeight; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment