Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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