Android全屏模式处理

1. 状态栏和导航栏

if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
			// 透明状态栏
			getWindow().addFlags(
					WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
			// 透明导航栏
			getWindow().addFlags(
					WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
		}
</pre><pre name="code" class="java">或者这是theme
<pre name="code" class="java"><style name="FullBleedTheme" parent="android:Theme.Holo.Light.NoActionBar.TranslucentDecor">
        <!-- API 19 theme customizations can go here. -->

 
 

2  设置状态栏和ActionBar背景一直 

private void initSystemBar() {
		View view = getWindow().getDecorView();

		int status = 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;

		boolean isFull = view.getSystemUiVisibility() == status;
		if (isFull) {
			showSystemUI(view);
			int actionBarColor = Color.parseColor("#DDDDDD");
			mTintManager.setStatusBarTintColor(actionBarColor);
		} else {
			hideSystemUI(view);
			int actionBarColor = Color.parseColor("#00000000");
			mTintManager.setStatusBarTintColor(actionBarColor);
		}
	}

3 . 

public void hideSystemUI(View view) {
		view.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);
	}

	public void showSystemUI(View view) {
		view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
				| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
				| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
	}


4

 SystemBarConfig config = tintManager.getConfig();
	        mList.setPadding(0, config.getPixelInsetTop(true), 0, config.getPixelInsetBottom());

注: 引用 https://github.com/jgilfelt/SystemBarTint

http://segmentfault.com/blog/masaila/1190000000403651


你可能感兴趣的:(Android全屏模式处理)