簡體   English   中英

更改操作欄的顏色

[英]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文件中做什么?

要改變你的顏色只設置colorPrimarycolors.xml文件。

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

在此處輸入圖片說明

您可以參考此鏈接以獲取更多信息

Android清單文件向Android系統顯示有關您的應用程序的基本信息。

android:theme

您正在定義對樣式資源的引用,該樣式資源為應用程序中的所有活動定義了默認主題。 各個活動可以通過設置自己的主題屬性來覆蓋默認設置。 有關更多信息,請參見樣式和主題開發人員指南。

在這里,您可以找到有關清單清單中的 application元素的更多信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM