Skip to content

Instantly share code, notes, and snippets.

@hl5pma
Created February 4, 2015 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hl5pma/d17a229bdfc803036c4c to your computer and use it in GitHub Desktop.
Save hl5pma/d17a229bdfc803036c4c to your computer and use it in GitHub Desktop.
import android.content.Context;
import android.content.res.Resources;
import android.util.TypedValue;
public class UiUtils {
private UiUtils() {
}
public static int getStatusBarHeight(Context context) {
final Resources res = context.getResources();
final int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
if (resourceId != 0) {
return res.getDimensionPixelSize(resourceId);
} else {
return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25f, res.getDisplayMetrics()) + 0.5f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment