[Android]通知栏与操作栏的高度-State Bar & Navigation Bar
1.通知栏
public static int getStatusBarHeight() { Resources resources = Resources.getSystem(); int resourceId = Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { return resources.getDimensionPixelSize(resourceId); } return 0; }
2.虚拟键操作栏
public static int getNavigationBarHeight() { Resources resources = Resources.getSystem(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { return resources.getDimensionPixelSize(resourceId); } return 0; }
版权声明:欢迎自由转载-非商用-非衍生-保持署名。作者:Benhero,博客地址:http://www.cnblogs.com/benhero/