第一种类似主流APP的搜索栏
ActionBar actionBar = getSupportActionBar(); actionBar.hide(); if (Build.VERSION.SDK_INT >= 21) { View decorView = getWindow().getDecorView(); int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; decorView.setSystemUiVisibility(option); getWindow().setStatusBarColor(Color.TRANSPARENT); }
注意(必须是安卓5.0以上会显示这种效果);
第二种完全隐藏
1.隐藏标题栏,状态栏。
ActionBar actionBar = getSupportActionBar(); actionBar.hide(); View decorView = getWindow().getDecorView(); int option = View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(option); initView();
2.隐藏标题栏,状态栏,导航栏。
View decorView = getWindow().getDecorView(); int option = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(option); ActionBar actionBar = getSupportActionBar(); actionBar.hide();