直接去这儿看吧:
第一个/Androi沉浸式模式
实现代码:(亲测可用)
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus && Build.VERSION.SDK_INT >= 19) {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
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);
}
}
第二个:Android沉浸式(透明)状态栏适配
第三个:
Android 系统状态栏沉浸式/透明化完整解决方案
第四个:
http://www.jianshu.com/p/49f1014fb3c4
自己试过的:
手机系统5.0
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//取消标题栏//去掉标题栏注意这句一定要写在setContentView()方法的前面,不然会报错的
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
}
AndroidManifest.xml内:
效果:
Androi沉浸式模式