标签:透明通知栏
从4.4开始,Google为Android增加了透明状态栏和导航栏的功能,只需要加入少量代码就可以实现。如图:
在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>
如果希望修改通知栏颜色,可以参考Github大牛的Demo:
https://github.com/jgilfelt/SystemBarTint
其中的library只有一个SystemBarTintManager类,可以拷贝到自己的工程中使用,这样就不用依赖那个library了。
标签:透明通知栏
原文地址:http://blog.csdn.net/myatlantis/article/details/43194917