更改操作栏的颜色

Changing the color of an Action Bar

<style name="Theme_Base_App" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

我只是将上面的代码复制到我的 styles.xml 文件中,然后我复制了

android:theme="@style/Theme_Base_App"

进入我的清单文件。我现在如何更改此操作栏的颜色?

此外,有人可以通过使用这些代码行向我解释我到底在做什么吗?清单文件有什么用?我在 Styles.xml 文件中做什么?

要更改颜色,只需在 colors.xml 文件中设置 colorPrimary

<?xml version="1.0" encoding="utf-8"?>
<resources> 
    <color name="primary">your color</color>
</resources>

使用此样式 您正在定义继承自 AppCompat 主题的自定义主题。

  <!-- inherit from the material theme -->
  <style name="Theme_Base_App" parent="Theme.AppCompat.Light.DarkActionBar">

    <!-- Main theme colors -->
    <!--   your app branding color for the app bar -->
    <item name="colorPrimary">@color/colorPrimary</item>

    <!--   darker variant for the status bar and contextual app bars -->
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>

  </style>

您可以参考这个 link 用于 more info

Android Manifest 文件向 Android 系统提供有关您的应用程序的基本信息。有

android:theme

you are defining a reference to a style resource defining a default theme for all activities in the application. Individual activities can override the default by setting their own theme attributes. For more information, see the Styles and Themes developer guide.

在这里,您可以在清单中找到有关 Manifest and application element 的更多信息。