如何在透明状态栏下显示内容在Kitkat
问题描述:
我目前在我的手机中运行Kitkat(4.4.2),并且我安装了一个应用程序。如何在透明状态栏下显示内容在Kitkat
在这个应用程序中,状态栏是透明的,并显示下面的应用程序的内容。 请参阅图片。
我应该怎么做我的程序。
在此先感谢。
答
由于WarrenFaith建议,http://blog.raffaeu.com/archive/2015/04/11/android-and-the-transparent-status-bar.aspx包含此问题的详细答案。
答
您可以使用此库在kitkat中着色状态栏颜色。
https://github.com/jgilfelt/SystemBarTint
以下是代码MainActivity.java
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.setFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
w.setFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
SystemBarTintManager systemBarTintManager = new SystemBarTintManager(this);
systemBarTintManager.setStatusBarTintEnabled(true);
systemBarTintManager.setStatusBarTintColor(Color.parseColor("#689F38"));
}
用于搜索的关键词是: “Android的透明状态栏”。第一次打击:http://blog.raffaeu.com/archive/2015/04/11/android-and-the-transparent-status-bar.aspx我现在要投票结束,因为这不是一个主题问题所以。请阅读[常见问题]了解更多关于如何提出问题的细节。 – WarrenFaith
感谢WarrenFaith,但是在博客中提到的状态栏提到了一些阴影。如何处理? –
你应该开始搜索!两次点击找到这个:http://stackoverflow.com/questions/21865621/transparent-status-bar-before-4-4-kitkat看到右下方列表标题:“相关”你可以找到很好的相关问题和答案那里! – WarrenFaith