沉浸式状态栏改变

activity_main.xml的布局放了一张全屏的图片

[html]  view plain  copy
  1. <ImageView  
  2.      android:scaleType="fitXY"  
  3.      android:src="@drawable/l"  
  4.      android:layout_width="match_parent"  
  5.      android:layout_height="match_parent" />  

res-New-Android resource file新建values-v19的styles.xml,和values-v21的styles.xml



点击OK后会创建好这两个文件

在原本的values-styles.xml里面(标红的是需要改的地方)

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>


    <style name="AppTheme" parent="AppTheme.Base"></style>
</resources>
在新建的values-v19的styles.xml里面

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="AppTheme.Base">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
    </style>
    
</resources>
在新建的values-v21的styles.xml里面
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="AppTheme.Base">
        <!--透明状态栏-->
        <item name="android:windowTranslucentStatus">true</item>
        <!--透明导航栏-->
        <item name="android:windowTranslucentNavigation">true</item>
        <!--使状态栏,导航栏可绘制-->
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    </style>
    
</resources>
最后清单文件中引入的是这个


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值