[英]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文件中做什么?
要改變你的顏色只設置colorPrimary
在colors.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.