如何在 Kitkat 中显示透明状态栏下方的内容
How to show content below transparent status bar in Kitkat
我目前 运行 Kitkat (4.4.2) 在我的 phone 中,我安装了一个应用程序。
在这个应用中,状态栏是透明的,下面显示的是应用的内容。
请看图片。
在我的程序中应该怎么做。
提前致谢。
正如 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"));
}
我目前 运行 Kitkat (4.4.2) 在我的 phone 中,我安装了一个应用程序。
在这个应用中,状态栏是透明的,下面显示的是应用的内容。 请看图片。
在我的程序中应该怎么做。
提前致谢。
正如 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"));
}