工具类中使用
// 隐藏底部的虚拟按键 方法一 滑动屏幕 可重新显示出来public static void hideBottomUIMenu(Activity activity) {//隐藏虚拟按键,并且全屏if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower apiView v = activity.getWindow().getDecorView();v.setSystemUiVisibility(View.GONE);} else if (Build.VERSION.SDK_INT >= 19) {//for new api versions.View decorView = activity.getWindow().getDecorView();int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;decorView.setSystemUiVisibility(uiOptions);}}// 方法二 滑动也不能重新显示public static void hideBottomUIMenu2(Activity activity) {//隐藏虚拟按键,并且全屏if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower apiView v = ((Activity) MyApplication.getContext()).getWindow().getDecorView();v.setSystemUiVisibility(View.GONE);} else if (Build.VERSION.SDK_INT >= 19) {Window _window = ((Activity) MyApplication.getContext()).getWindow();WindowManager.LayoutParams params = _window.getAttributes();params.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE;_window.setAttributes(params);}}