UI:Android 系统状态栏设置透明Translucent(

2016-12-02  本文已影响83人  蜂鸟之歌

自己总结的实现以下效果的几种方式(需要在values-v19/21配置)

1. 只需要设置主题属性,原理是将状态栏透明,再利用android:fitsSystemWindows属性,可以根据需要单独在控件上设置该属性。

<style name="AppTheme" parent="Theme.AppCompat.Light">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
</style>

或者(?)

<style name="AppTheme" parent="Theme.AppCompat.Light">
  <item name="android:windowDrawsSystemBarBackgrounds">true</item>  
  <item name="android:statusBarColor">@android:color/transparent</item>  
  <item name="android:fitsSystemWindows">true</item>
</style>

Values:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
values-v19:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
values-v21:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">true</item>

<item name="android:statusBarColor">@android:color/transparent</item>
</style>

2. 暂时没发现有更方便的方法。。。

3. 关于沉浸Immersive

http://www.jianshu.com/p/34a8b40b9308
http://blog.csdn.net/sdvch/article/details/44209959

上一篇下一篇

猜你喜欢

热点阅读