安卓4.4后实现透明状态栏
2015-06-19 10:08
239 查看
在安卓4.4后实现透明状态栏
基于SystemBarTint实现(SystemBarTint链接:https://github.com/jgilfelt/SystemBarTint)
第一步
首先将SystemBarTintManager类放入项目。
下载链接:http://download.csdn.net/detail/s1e1s/8821609
第二步
在activity对应的布局文件中加入两行代码
android:fitsSystemWindows="true"
android:clipToPadding="true"
第三步
onCreat()方法中调用initSystemBar()方法
颜色资源文件
在res->values 新建color.xml
基于SystemBarTint实现(SystemBarTint链接:https://github.com/jgilfelt/SystemBarTint)
第一步
首先将SystemBarTintManager类放入项目。
下载链接:http://download.csdn.net/detail/s1e1s/8821609
第二步
在activity对应的布局文件中加入两行代码
android:fitsSystemWindows="true"
android:clipToPadding="true"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:clipToPadding="true" >
第三步
onCreat()方法中调用initSystemBar()方法
<span style="white-space:pre"> </span>private void initSystemBar() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); //使用颜色资源 //tintManager.setStatusBarTintResource(R.color.systemBar_color); //使用图片资源 tintManager.setStatusBarTintDrawable(getResources().getDrawable(R.drawable.ic_top_title_background)); } <span style="white-space:pre"> </span>@TargetApi(19) private void setTranslucentStatus(boolean on) { Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); }
颜色资源文件
在res->values 新建color.xml
<?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <color name="systemBar_color">#2aa45a</color><!--导航栏背景颜色 --> </resources>
相关文章推荐
- Cycle listII
- IOS之地图和定位应用开发
- transform ,transition, @keyframe animantion 对比
- 输入个人信息按年龄大小排列
- node.js及相关组件安装
- kalman滤波
- 怎样在Xcode 6中使用矢量图形
- Linux read系统调用
- struts2核心和工作原理
- 建立删除不掉的文件夹
- POJ 1664 放苹果
- Linu下安装php及测试
- 51cto给了我事业的目标
- 游戏引擎开发之音乐播放(一)
- storm入门原理
- eclipse 安装jetty插件
- GetAdaptersInof获取本地连接的网卡信息,排除无线网卡和虚拟网卡
- 给Sublime text2安装Zen Coding插件
- 基础学习总结(六)--getContentRolver()的应用、内容监听者ContentObserver
- git命令