如何使Android 4.4的透明的状态栏? [英] How to make a transparent status bar in Android 4.4?

查看:182
本文介绍了如何使Android 4.4的透明的状态栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打一个透明的状态栏在我的Andr​​oid 4.4的应用程序。
我该怎么做呢?

我累了:

 <样式名称=AppTheme父=@风格/ Theme.AppCompat.Light.NoActionBar>
        <项目名称=colorPrimary> @彩色/ skipPrimary< /项目>
        <项目名称=colorPrimaryDark> @彩色/ skipPrimary< /项目>
        <项目名称=colorAccent> @彩色/ skipPrimary< /项目>
    < /风格>

和在清单:

 <应用
        机器人:名字=应用程序
        机器人:allowBackup =真
        机器人:图标=@绘制/ ic_launcher
        机器人:主题=@风格/ AppTheme>

和在活动:

 <活动
            机器人:名字=。activities.StartActivity
            机器人:configChanges =方向| keyboardHidden |键盘|屏幕尺寸
            机器人:screenOrientation =画像
            机器人:主题=@风格/ AppTheme
            机器人:windowSoftInputMode =adjustResize | stateHidden/>


解决方案

您也可以做的是设置什么状态在您的活动设置它吧你的背景,甚至相同的颜色暗的阴影。

您可以设置与下列code getWindow()您的活动状态栏颜色setStatusBarColor(getResources()的getColor(R.color.your_color));

如果你想使用你的颜色暗的阴影,你可以通过改变你的颜色的HSB做到这一点。对于这样做,你可以看到这篇文章的更详细的方法:的 Android的变化通过转换状态栏的颜色现有颜色的HSB

I want to make a transparent status bar in my application in Android 4.4. How do I do that?

I tired:

<style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/skipPrimary</item>
        <item name="colorPrimaryDark">@color/skipPrimary</item>
        <item name="colorAccent">@color/skipPrimary</item>
    </style>

and in the manifest:

<application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:theme="@style/AppTheme" >

and in the activity:

<activity
            android:name=".activities.StartActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme"
            android:windowSoftInputMode="adjustResize|stateHidden" />

解决方案

What you can also do is set the status bar a darker shade of your background or even the same color by setting it in your activity.

You can set the status bar color in your activity with the following code getWindow().setStatusBarColor(getResources().getColor(R.color.your_color));.

If you want to use a darker shade of your color you can do it by changing your color's HSB. For a more detailed way of doing that you can read this post: Android change status bar color by converting existing color's HSB

这篇关于如何使Android 4.4的透明的状态栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆