簡體   English   中英

如何更改片段中的操作欄標題顏色

[英]How to change Action Bar title color in fragment

我在Fragment中有一個導航抽屜。我想在此Fragment中更改操作欄標題的顏色。 對於其他所有屏幕,我都使用了自定義操作欄,並且該欄的工作效果很好。 我還指定了操作欄標題的樣式。 這是我的style.xml

<resources xmlns:android="http://schemas.android.com/apk/res/android">

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.

    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

<style name="CustomActionBarTheme"  parent="@android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar"
       parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>

 <!-- ActionBar title text -->
<style name="MyActionBarTitleText"   parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColorPrimary">@color/ActionBar_text</item>
</style>

 <style name="PoppupMenu" parent="android:Widget.PopupMenu">
    <item name="android:popupBackground">@android:color/white</item>
 </style>

您想要將CustomActionBarTheme的父級更改為@ style / AppTheme

<style name="CustomActionBarTheme"  parent="@stye/AppTheme">

然后將android:textColorPrimary更改為android:textColor

<item name="android:textColor">@color/ActionBar_text</item>

暫無
暫無

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

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