android实现沉浸式状态栏

	最近发现起点小说客户端实现了沉浸式状态栏,非常漂亮,就专门了解了一下。在android4.4以后,软件可以自己设置状态栏颜色,将屏幕显示成一个整体,带来更好的美感。所谓沉浸式状态栏,即应用程序顶部的背景与状态栏的背景非常融洽的连接在一起,增加了屏幕的使用效率,看起来更美观。

如下图:


android实现沉浸式状态栏_第1张图片


在activity中实现如下方法:

if (Build.VERSION.SDK_INT>=19) {
Window window=getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATI ON);
SystemBarTintManager manager=new SystemBarTintManager(this);
manager.setStatusBarTintEnabled(true);
manager.setNavigationBarTintEnabled(true);
manager.setStatusBarTintColor(Color.parseColor("#b4232e"));
manager.setNavigationBarTintColor(Color.parseColor("#b4232e"));
}

其中SystemBarTintManager.java的源码下载地址如下:

http://download.csdn.net/detail/chen00yin/9106403


你可能感兴趣的:(android)