android - Activity 的状态栏颜色无明显原因不同

标签 android xml statusbar

我创建了一个新 Activity ,由于某种原因,当它被使用时,它在状态栏中使用不同的颜色。奇怪的是,在“设计”预览中它呈现了正确的颜色。

下面是两个屏幕截图,较深的颜色是正确的颜色。

不正确 enter image description here 正确 enter image description here

主题与其他 .xml 布局相同,因此我很难确定此错误的来源。下面是布局代码:

activity_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.brewguide.android.coffeebrewguide.MenuActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            />

    </android.support.design.widget.AppBarLayout>

<LinearLayout
    android:id="@+id/myfragment"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    </LinearLayout>

</android.support.design.widget.CoordinatorLayout>

我不确定包含哪些其他代码对诊断此问题有用。


编辑:

样式.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="DescriptionTextView">
    <item name="android:textColor">@color/colorPrimaryDark</item>
    <item name="android:background">@color/mainBackground</item>
</style>

<!--style for the start button in the clock view layout-->
<style name="AppTheme.Button.Start" parent="Widget.AppCompat.Button.Colored">
    <item name="colorButtonNormal">@color/complimentaryLeft</item>
    <item name="android:textColor">@color/cardview_dark_background</item>
</style>

<!--style for the stop button in the clock view layout-->
<style name="AppTheme.Button.Stop" parent="Widget.AppCompat.Button.Colored">
    <item name="colorButtonNormal">@color/colorPrimary</item>
    <item name="android:textColor">@color/cardview_dark_background</item>
</style>

<!--style for the reset button in the clock view layout-->
<style name="AppTheme.Button.Reset" parent="Widget.AppCompat.Button.Colored">
    <item name="colorButtonNormal">@color/colorAccent</item>
    <item name="android:textColor">@color/cardview_light_background</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@android:color/white</item>
</style>

最佳答案

我遇到了同样的问题。对我来说,这是第二个 styles.xml 文件的问题(仍然不确定为什么我有两个)。导致问题的具体行是:

<item name="android:statusBarColor">@android:color/transparent</item>

我在您发布的 styles.xml 中没有看到这一点,但也许它会对其他人有所帮助。

关于android - Activity 的状态栏颜色无明显原因不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45538453/

相关文章:

android - SupportMapFragment.getmap() 返回 null

php - 如何通过 Curl 和 PHP 发送 SOAP XML?

java - 如何在 CollapsingToolbarLayout 内设置 Toolbar 的重力?

android - 防止触摸屏幕时出现android状态栏

ios - 在 iOS7 中如何防止查看内容移至状态栏下方?

ios7 - 如何隐藏iOS状态栏

java - 用 Joda-time 进行时间计算?

android - Chrome 自定义标签初始 Okta Auth 不重定向回来

android - 有没有办法只组装一种风格的 androidTest 版本?

java - dom4j-java-如何更改属性的值