定义工具类,隐藏状态栏和虚拟按键导航栏
/* * 常用工具类 * */ public class Common { //隐藏状态栏和导航栏 public static void hideBar(Activity activity){ if(Build.VERSION.SDK_INT<16){ int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN; activity.getWindow().setFlags(flag,flag); }else{ int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; activity.getWindow().getDecorView().setSystemUiVisibility(uiFlags); } } }