Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 自定义Appbar不更改颜色_Android_Android Layout_Android Theme - Fatal编程技术网

Android 自定义Appbar不更改颜色

Android 自定义Appbar不更改颜色,android,android-layout,android-theme,Android,Android Layout,Android Theme,即使我在自定义主题的样式中定义了colorPrimaryDark,appbar仍保持半透明。代码的重要部分如下所示 styles.xml <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrima

即使我在自定义主题的样式中定义了colorPrimaryDark,appbar仍保持半透明。代码的重要部分如下所示

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" />

@颜色/原色
@颜色/原色暗
@颜色/颜色重音
假的
真的
这是appbar布局中的工具栏:

<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>

这是我在清单中为该活动定义的:

<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>


任何关于我错在哪里的建议。其他所有东西,如工具栏,都工作正常。

请尝试更改此行

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



只需在清单中的标记中添加什么是主题?Apptheme。android:theme=“@style/AppTheme”尝试过。不工作。相反,标题颜色变为黑色。已还原更改。祝您好运,希望您能找到答案
<style name="AppTheme.AppBarOverlay" parent="AppTheme" />