状态栏

注本文只用作个人记忆,不做其他用途

1、内容延伸至状态栏之上,并不是改变状态栏颜色

<!-- Base application theme. -->
    <style name="BaseAppTheme" 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>

        <item name="android:screenOrientation">portrait</item>
        <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item>
        <item name="android:windowTranslucentNavigation" tools:targetApi="kitkat">true</item>
    </style>

    <style name="BaseAppTheme.Trans">
        <!--<item name="android:windowBackground">@android:color/transparent</item>-->
        <item name="android:windowIsTranslucent">true</item>
    </style>
     //清单文件配置
    <activity android:name=".ui.splash.SplashActivity"
            android:theme="@style/BaseAppTheme.Trans">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

这里写图片描述
这是4.4系统的截图,状态栏有黑色阴影,5.0效果要好一点,但是有一个缺陷
这里写图片描述
这一部分就是需要在布局中算到你的title高度中,否则title上的字会与电池重叠

2、改变状态栏颜色

     // TODO:适配4.4
    @TargetApi(Build.VERSION_CODES.KITKAT)
    protected void setStatusBarTranslucent() {
        if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                //下面三句都是需要导入三方库的   
                //compile  'com.readystatesoftware.systembartint:systembartint:1.0.3'
            SystemBarTintManager tintManager = new SystemBarTintManager(this);
            tintManager.setStatusBarTintEnabled(true);
            tintManager.setStatusBarTintResource(R.color.colorPrimary);
        }
    }

    <activity android:name=".ui.home.HomeActivity"
            android:theme="@style/BaseAppTheme">
    </activity>

这里写图片描述
这里进行区分写成两种颜色,在应用中一般都是颜色相同的

…..后续,边码代码边记

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值