转-android沉浸式状态栏:Translucent System Bar 的最佳实践
来源:互联网 发布:mac flash player 21 编辑:程序博客网 时间:2024/05/29 16:14
转自简书Translucent System Bar 的最佳实践
安卓从4.4以后加入了状态栏可改变颜色的特性,通常都成为沉浸式状态栏。简单的说就是让状态栏不再是单调的黑色,实在太丑了,就像苹果那样状态栏与app是一体的。这样看上去友好很多吧。
以下是我学习作者的教程后自己的实践:
1.设置application的theme,同时要针 对各个android版本进行匹配
2.同时需要在每个布局文件的根布局加属性 android:fitsSystemWindows=”true”,根布局的背景颜色也要设置为状态栏一致的颜色android:background=”@color/top_bar_bg”
第二个步骤不设置在4.4版本中状态栏是白色的
下面会给出不同api版本的style样式
分别在res目录下新建value-19,value-21,value-23文件夹,并创建style.xml文件,当然默认的value下也要有普通的style文件
1.v19 android4.4
<!-- Application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentNavigation">true</item> </style>
2.v21 android 5.0
<!-- Application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowTranslucentStatus">false</item> <item name="android:windowTranslucentNavigation">true</item> <!--Android 5.x开始需要把颜色设置透明,否则导航栏会呈现系统默认的浅灰色--> <item name="android:statusBarColor">@color/top_bar_bg</item> </style>
3.v23 android 6.0
<!-- Application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentNavigation">true</item> <!--Android 5.x开始需要把颜色设置透明,否则导航栏会呈现系统默认的浅灰色--> <item name="android:statusBarColor">@color/top_bar_bg</item> </style>
0 0
- 转-android沉浸式状态栏:Translucent System Bar 的最佳实践
- (4.2.37.1)沉浸式状态栏Android开发:Translucent System Bar 的最佳实践
- Android开发 -- Translucent System Bar 的最佳实践(沉浸式状态栏)
- Android开发:Translucent System Bar 的最佳实践(沉浸式)
- Android Translucent System Bar 的最佳实践
- Android UI之沉浸式状态栏Translucent System Bar
- Android开发:Translucent System Bar 的最佳实践
- Android开发:Translucent System Bar 的最佳实践
- Android Design Support Library--Translucent System Bar 的最佳实践
- Android开发:Translucent System Bar 的最佳实践
- Android开发:Translucent System Bar 的最佳实践
- Android30--Android之Translucent System Bar 的最佳实践
- Android-Translucent System Bar 的最佳实践-Oak先生
- Android 开发:Translucent System Bar 的最佳实践
- Android 开发:Translucent System Bar 的最佳实践
- Android开发:Translucent System Bar 的最佳实践
- Android开发:Translucent System Bar 的最佳实践
- Translucent System Bar 的最佳实践
- Xcode 配置 路径
- 各大牛逼网站推荐系统
- Android JNI学习笔记2
- AttributedString
- 秒杀核心设计(减库存部分)-防超卖与高并发
- 转-android沉浸式状态栏:Translucent System Bar 的最佳实践
- WPF获取键盘状态(如WPF组合键)
- activity管理
- 最大子序列和
- Java反射和工厂模式
- 文章的相关性对网站优化到底有多重要?
- 每天一命令(15)df - report file system disk space usage
- 获取RSA文件的MD5和SHA1
- 文件的MIME-TYPE