Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.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 如何使用Appcompat更改操作栏背景色_Android_Android Actionbar_Android Support Library_Background Color_Android Appcompat - Fatal编程技术网

Android 如何使用Appcompat更改操作栏背景色

Android 如何使用Appcompat更改操作栏背景色,android,android-actionbar,android-support-library,background-color,android-appcompat,Android,Android Actionbar,Android Support Library,Background Color,Android Appcompat,是的,我知道网上有很多类似的问题和答案。我在过去的三个小时里检查了所有的。没有一个解决办法对我有效 我只是启动了一个Android Studio(v1.0.2)项目,默认情况下由v7 AppCompat库提供 我将styles.xml更改为: <?xml version="1.0" encoding="utf-8"?> <resources> <style name="MyAppTheme" parent="Theme.AppCompat.Light">

是的,我知道网上有很多类似的问题和答案。我在过去的三个小时里检查了所有的。没有一个解决办法对我有效

我只是启动了一个Android Studio(v1.0.2)项目,默认情况下由v7 AppCompat库提供

我将styles.xml更改为:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light">
        <item name="actionBarStyle">@style/MyActionBar</item>
    </style>
    <style name="MyActionBar" parent="@style/MyAppTheme">
        <item name="android:background">@android:color/holo_red_dark</item>
    </style>
</resources>
我正在寻找一种最简单的方法,将动作栏的背景颜色全局更改为所需的颜色


现在,操作栏是完全白色的,菜单按钮上有三个黑点。

使用Appcompat rel 21.0.x,只需使用如下内容:

<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">

    <!-- Set AppCompat’s color theming attrs -->
    <item name=”colorPrimary”>@color/my_color</item>
    <item name=”colorPrimaryDark”>@color/my_color_darker</item>

</style>

我发现了很多基本的应用程序示例,可以在AS中进行探索。也许没有其他文档可以描述这么简单的事情。。。
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">

    <!-- Set AppCompat’s color theming attrs -->
    <item name=”colorPrimary”>@color/my_color</item>
    <item name=”colorPrimaryDark”>@color/my_color_darker</item>

</style>
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
    <!-- ... -->
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
     <!-- default value is @null -->
     <item name="background">....</item>   
</style>