首页 > 其他 > 详细

开源项目修改状态栏

时间:2015-09-17 19:57:27      阅读:302      评论:0      收藏:0      [点我收藏+]

android 4.4 提供了一套能透明的系统ui样式给状态栏和导航栏,这样的话就不用向以前那样每天面对着黑乎乎的上下两条黑栏了,还可以调成跟activity 一样的样式,形成一个完整的主题。


首先要打开activity的透明主题功能,可以把activity的主题设置继承*.TranslucentDecor 主题,然后设置android:windowTranslucentNavigation 或者android:windowTranslucentStatus的主题属性为true,又或者在activity的代码里面开启FLAG_TRANSLUCENT_NAVIGATION 或是 FLAG_TRANSLUCENT_STATUS的window窗口标识。由于透明主题不能在4.4以前的版本里面使用,所以系统样式跟以前没有区别,也就是看不到任何变化,这是一个兼容模式,这个模式可以兼容到api 10;

<activity

            android:name=".MainActivity"

            android:label="@string/app_name" 

            android:theme="@android :style/Theme.Holo.NoActionBar.TranslucentDecor"

            android:windowTranslucentNavigation="true"

           >

然后下载 SystemBarTint,地址是https://github.com/hexiaochun/SystemBarTint,将里面的SystemBarTintManager.java直接拷到自己的项目中,在activity的onCreate()添加如下代码:

SystemBarTintManager tintManager = new SystemBarTintManager(this);
		tintManager.setStatusBarTintEnabled(true);
		tintManager.setNavigationBarTintEnabled(true);
		tintManager.setTintColor(Color.RED);



开源项目修改状态栏

原文:http://my.oschina.net/u/1463920/blog/507786

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!