Translucent System Bar
来源:互联网 发布:神州数码通用软件 编辑:程序博客网 时间:2024/05/23 02:16
小米应用商店和内置的天气软件截图如下,我们可以看到顶部的通知栏和界面色调融为一体。这种bar称为Translucent System Bar
下面就对应实现这两种效果
第一种方式:
1、 在values、values-v19、values-v21的style.xml都设置一个 Translucent System Bar 风格的Theme
value/style.xml
<style name="ImageTranslucentTheme" parent="android:Theme.Light"> <!-- 在Android 4.4之前的版本上运行,直接跟随系统主题 --></style>
value-19/style.xml
<style name="ImageTranslucentTheme" parent="android:Theme.Holo.Light.DarkActionBar"> <item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentNavigation">true</item></style>
value-21/style.xml
<style name="ImageTranslucentTheme" parent="android:Theme.Holo.Light.DarkActionBar"> <item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentNavigation">true</item> <!-- Android 5.x开始需要把颜色设置透明,否则导航栏会呈现系统默认的浅灰色 --> <item name="android:statusBarColor">@android:color/transparent</item></style>
2、在AndroidManifest.xml中对指定Activity的theme进行设置
<activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/ImageTranslucentTheme" > </activity>
3、在Activity的布局文件中设置背景图片,同时,需要把android:fitsSystemWindows设置为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:background="@drawable/site" android:fitsSystemWindows="true" tools:context="${relativePackage}.${activityClass}" ></RelativeLayout>
运行效果如下:
第二种方式:
1、其他设置不变,在Activity的布局文件中设置根布局背景颜色和标题栏的颜色
<LinearLayout 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:background="#FF7B35" android:fitsSystemWindows="true" android:orientation="vertical" tools:context="${relativePackage}.${activityClass}" > <RelativeLayout android:layout_width="match_parent" android:layout_height="80dp" android:background="#FF7B35" > <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="JYY" android:textColor="@android:color/white" android:textSize="25dp" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#F0F0F0" > </RelativeLayout> </LinearLayout>
运行效果如下:
0 0
- Translucent System Bar
- Android开发:Translucent System Bar
- Android Translucent System Bar 的最佳实践
- Android ToolBar+Translucent System Bar的用法
- Translucent System Bar 的最佳实践
- Android ToolBar+Translucent System Bar的用法
- android 任务栏Translucent System Bar 设置
- Translucent System Bar 的最佳实践
- Translucent System Bar 的最佳实践
- Translucent System Bar 半透明状态栏的使用
- Android Translucent System Bar使用小结
- Android 4.4 实现透明状态栏Translucent system bar(Status bar)
- Android开发:Translucent System Bar 的最佳实践
- Android开发:Translucent System Bar 的最佳实践
- Android Translucent System Bar + actionbarsherlock + SlidingTabLayout 综合实践
- Android Design Support Library--Translucent System Bar 的最佳实践
- Translucent System Bar (通知栏和App界面融为一体)
- Android开发:Translucent System Bar 的最佳实践
- spark 官方文档(1)——提交应用程序
- 我的nas集群
- CSS3滚动视差效果的制作技巧
- PAT甲级练习题A1004. Counting Leaves
- linux入门使用(1)
- Translucent System Bar
- SOJ 2668 C(n,k) 数论
- Android中项目中集成百度地图
- 程序员的创业陷阱:接私活
- int数组为什么一般不能用memset初始化每个元素
- NYOJ 22 素数求和问题
- Mac Firefox vimperator
- JAVA中的反射机制
- python matplotlib绘图使用中文字体