美文网首页
UI:Android 系统状态栏设置透明Translucent(

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

作者: 蜂鸟之歌 | 来源:发表于2016-12-02 19:58 被阅读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

    相关文章

      网友评论

          本文标题:UI:Android 系统状态栏设置透明Translucent(

          本文链接:https://www.haomeiwen.com/subject/cydqmttx.html