【发布时间】:2017-08-16 11:57:09
【问题描述】:
我正在尝试将状态栏的颜色更改为带有灰色图标的白色。我已经尝试了几乎所有代码解决方案来解决这个问题,但没有一个对我有用。
我正在使用这个 java 函数来改变它,我也发布了我的 style(21) 代码。
public static void statusBarColor(Window window, Context ctx) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//Window window = getActivity().getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(ctx.getResources().getColor(R.color.statusbar_color));
}
}
这是我的 Java 代码,但经过一千次尝试后仍无法正常工作。 以下是我的 style.xml (21)
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
</style>
如果您认为它与其他问题重复,那么我应该让您现在我已经尝试了 3,4 页的谷歌搜索并实施了它们。
【问题讨论】:
-
你的 xml 现在做了什么?
标签: android android-layout material-design android-view statusbar