Android沉浸式状态栏 Android实现沉浸式状态栏
shineflowers 人气:0想了解Android实现沉浸式状态栏的相关内容吗,shineflowers在本文为您仔细讲解Android沉浸式状态栏的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Android,沉浸式,状态栏,下面大家一起来学习吧。
前段时间,项目中用到了沉浸式的状态栏,在此记录一下,代码如下:
package com.jackie.immersive; import android.os.Build; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @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); } } }
效果如下:
加载全部内容