我已经调试了很长一段时间,似乎无法找到解决方案。我的问题是,即使我使用xml行查看我的状态栏也是白色的
android:fitsSystemWindows="true"
问题的图片可以在下面找到。无论如何,我尝试了多种解决方案,但没有一种方法有效。这是我的工具栏的代码。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="3dp"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="@style/AppTheme.ActionBarStyle"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/actionbar_color"/>
</android.support.design.widget.AppBarLayout>
以下是AppTheme.ActionBarStyle
的代码<style name="AppTheme.ActionBarStyle" parent="Widget.AppCompat.Toolbar">
<item name="android:background">@color/actionbar_color</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="theme">@style/ThemeOverlay.AppCompat.Light</item>
</style>
这是问题的图片。我在这里错过了什么?另请注意,我确实在apptheme中设置了颜色
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Set AppCompat’s color theming attrs -->
<item name="colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="colorAccent">@color/accent</item>
</style>
答案 0 :(得分:0)
如果您的手机是Lollipop之前,那么您将无法像这样实现它。您写的代码是正确的,并且会在Lollipop设备上正确显示。
答案 1 :(得分:0)
将这些样式设置添加到<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
可能有效:
decode "[1,2,3,4,null,\"hello\"]" :: (Maybe [Value])
Just [Number 1.0,Number 2.0,Number 3.0,Number 4.0,Null,String "hello"]
请注意,这仅适用于API-21(Lollipop)或更高版本。
答案 2 :(得分:0)
这有点令人尴尬,但我在我的Manifest文件中使用了不同的样式。这就是为什么它没有工作。