//获取虚拟按键的高度 public static int getNavigationBarHeight(Context context) { int result = 0; if (hasNavBar(context)) { Resources res = context.getResources(); int resourceId = res.getIdentifier("navigation_bar_height", "dimen", "androi
获取android屏幕上状态栏的高度方法网上很多这里不再敖述,只举一个例子 Rect rect = new Rect();getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); rect.top便是状态栏的高度. 上面的rect.top为0 的原因是:不能在onCreate() , onResume() , onStart()里面使用. 在布局文档里面最外层的layout不能写成fill_parent
Google的官方文档是: https://developer.android.com/training/system-ui/navigation.html#behind 示例代码 1 View decorView = getWindow().getDecorView(); 2 // Hide both the navigation bar and the status bar. 3 // SYSTEM_UI_FLAG_FULLSCREEN is only available on Androi