简体   繁体   English

自定义应用栏不会更改颜色

[英]Custom Appbar not changing colour

The appbar remains translucent even though i've colorPrimaryDark defined in the styles of my custom theme. 即使我在自定义主题的样式中定义了colorPrimaryDark,应用程序栏仍然保持透明。 The significant part of the code is as follows. 该代码的重要部分如下。

styles.xml styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <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="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

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

This is where i've a toolbar in appbar layout: 这是我在应用栏布局中的工具栏所在的位置:

<android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id = "@+id/appBar"
        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" android:titleTextColor="#FFFFFF"
            app:popupTheme="@style/AppTheme.PopupOverlay">

        </android.support.v7.widget.Toolbar>

And this is what i've defined in the manifest for that activity: 这就是我在清单中为该活动定义的内容:

<activity
            android:name=".Activity5"
            android:label="Activity5"
            android:parentActivityName=".MainActivity"
            android:theme="@style/AppTheme.NoActionBar" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.divya.sampleapplication.MainActivity" />
        </activity>

Any suggestions on where i'm going wrong. 关于我要去哪里的任何建议。 Everything else like the toolbars and all are working fine. 工具栏等其他所有东西都工作正常。

Please Try to change this line 请尝试更改此行

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

To

<style name="AppTheme.AppBarOverlay" parent="AppTheme" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM