Android全屏显示:
1 @Override 2 protected void onCreate(Bundle savedInstanceState) { 3 super.onCreate(savedInstanceState); 4 //去掉Activity的标题栏 5 // 这句一定要在setContentView的前面 6 requestWindowFeature(Window.FEATURE_NO_TITLE); 7 8 setContentView(R.layout.activity_main); 9 10 //去掉状态栏 11 Window window = getWindow(); 12 window.addFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN); 13 //隐藏虚拟按键 14 //只是暂时隐藏,当用户产生交互行为(点击屏幕)时,虚拟按键还是会显示出来 15 window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); 16 17 }
Target API是21,默认继承Activity。效果图如下: