Android examples for User Interface:StatusBar
get Status Bar Height In Dp
//package com.java2s; import android.content.Context; import android.util.TypedValue; public class Main { private static TypedValue mTmpValue = new TypedValue(); public static int getStatusBarHeightInDp(Context context) { int result = 0; int resourceId = context.getResources().getIdentifier( "status_bar_height", "dimen", "android"); if (resourceId > 0) { result = getResourceValue(context, resourceId); }/*from ww w .ja v a2 s .c o m*/ return result; } public static int getResourceValue(Context context, int resId) { TypedValue value = mTmpValue; context.getResources().getValue(resId, value, true); return (int) TypedValue.complexToFloat(value.data); } }