Android 新特性沉浸式与透明状态栏

本文详细介绍了Android 4.4引入的沉浸式设计,区别了Translucent Bars(透明栏)和Immersive Mode(沉浸式模式)。通过设置系统主题和自定义主题,展示了如何实现透明和变色状态栏,并提供了使用开源库SystemBarTint改变状态栏颜色的方法。同时还探讨了在不同Android版本中的应用和效果。
摘要由CSDN通过智能技术生成

项目一个阶段完成,终于有时间可以把这段时间用到的东西整理整理了~_~,最近看到网上很多人都在整Android 4.4那个状态栏新特性,所以在自己项目中也加了这个,本来直接在国内看的资料,但国内说什么的都有,这让我有些迷糊,不知道这个新特性到底是怎么回事,后来只能去Google看了官方资料,终于知道这到底是怎么回事了。

一.有过的疑问

  1. 这个新特性到底是叫Translucent Bars(透明栏)还是叫Immersive Mode(沉浸式模式)呢?
  2. 到底这两个有什么区别呢?
  3. 怎么单独设置状态栏的颜色呢?

二.沉浸式设计是什么(沉浸设计的介绍)

沉浸就是让人专注在当前的目标情境下感到愉悦与满足,从而忘记时间的流逝。
这个也就是心流理论,心流理论的核心就是人们废寝忘食地投入一件事情的状态。
如果在这种状态就会出现对时间的错觉,也就是对时间的认知发生扭曲,在体验中将时间认知拉长或缩短。
所以,我们可以将为了沉浸式(心流)而进行的设计称为沉浸式设计也叫心流设计。

三.官网与别人对沉浸式的解释

别人的解释:

  • 沉浸式就是透明栏也就是Translucent Bars,就是状态栏与顶部颜色融为一体。
  • android 4.4中的透明渐变状态栏和虚拟按钮的样式,也就是沉浸式。就像Action Bar和状态栏融为一体。
    如图:
    状态栏与Action Bar融为一体了
    ps:到了5.0后就可以为状态栏设置颜色,所以我认为所谓的沉浸式状态栏不等于状态栏变色,即便是变色后跟ActionBar颜色一致。
  • Translucent Bars只是透明 状态/导航 栏的意思,4.4里是半透明的,在5.0里是全透明的。而Immersive Mode是属于全屏状态,隐藏了状态栏和导航栏。

Translucent Bars
4.4效果
4.4上的效果
5.0效果
5.0上效果

谷歌官方的解释

原文:
Immersive full-screen mode
To provide your app with a layout that fills the entire screen,
the new SYSTEM_UI_FLAG_IMMERSIVE flag for setSystemUiVisibility() (when combined with SYSTEM_UI_FLAG_HIDE_NAVIGATION) enables a new immersive full-screen mode. While immersive full-screen mode is enabled, your activity continues to receive all touch events. The user can reveal the system bars with an inward swipe along the region where the system bars normally appear. This clears the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag (and the SYSTEM_UI_FLAG_FULLSCREEN flag, if applied) so the system bars remain visible. However, if you’d like the system bars to hide again after a few moments, you can instead use the SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag.
Translucent system bars
You can now make the system bars partially translucent with new themes, Theme.Holo.NoActionBar.TranslucentDecor and Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable fitsSystemWindows for the portion of your layout that should not be covered by the system bars.
If you’re creating a custom theme, set one of these themes as the parent theme or include the windowTranslucentNavigation and windowTranslucentSta

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值