从4.4开始,Google为Android增加了透明状态栏和导航栏的功能,只需要加入少量代码就可以实现。如图:

仿IOS透明通知栏(仅支持4.4以上版本)_第1张图片

在Activity的布局文件父View中添加属性:android:fitsSystemWindows="true"android:clipToPadding="true"即可。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:custom="http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:fitsSystemWindows="true"    android:clipToPadding="true"    android:background="#ffe5ff3e">    <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:orientation="vertical">        <TextView            android:layout_width="match_parent"            android:layout_height="match_parent"            android:padding="16dp"            android:textSize="18sp"            android:text="@string/mytext" />    </LinearLayout></ScrollView>

如果不想要ActionBar,可以在AndroidManifest.xml或者Activity中去除,就得到上图效果。但是,透明通知栏只支持4.4以上的系统,在4.4以下还是会显示默认的通知栏。


如果希望修改通知栏颜色,可以参考Github大牛的Demo:

https://github.com/jgilfelt/SystemBarTint

其中的library只有一个SystemBarTintManager类,可以拷贝到自己的工程中使用,这样就不用依赖那个library了。

还可以参考这篇博文:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/1117/1992.html

更多相关文章

  1. Android实现类似有Table边框的布局
  2. Android 通知栏Notification的整合
  3. 2010-03-06 传智播客—Android(六)通知、样式、主题、HTML
  4. Android 软键盘将指定的布局顶上去
  5. [图文]为移植到Android平台上的Cocos2d-x项目添加xml布局文件

随机推荐

  1. Android(安卓)service跨进程调用和启动检
  2. Android(安卓)任意位置(指空间上的位置)弹
  3. 解决Android文档打开慢的问题
  4. foursquare -5 BroadcastReceiver 退出程
  5. Android源码分析:VoIP
  6. 自定义控件二: Paint Canvar 画几何图形
  7. Android(安卓)Html.fromhtml
  8. Afinal 0.3 发布,Android快速开发框架
  9. context、getApplicationContext()
  10. Android仿微信SwitchButton