1

我正在尝试主题夏洛克动作栏。我想将标题的颜色设置为白色。当我尝试执行以下操作时,标题会一起消失。

我还想在按下时更改操作项图标的背景颜色。

我试过什么?

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

    <!-- Variation on the Holo Light theme that styles the Action Bar -->
    <style name="Theme.Nomad" parent="Theme.Sherlock.Light">
        <item name="actionBarStyle">@style/Widget.Nomad.ActionBar</item>
        <item name="android:actionBarStyle">@style/Widget.Nomad.ActionBar</item>
        <item name="android:actionBarItemBackground">@drawable/actionbar_selectable_background</item>
        <item name="actionBarItemBackground">@drawable/actionbar_selectable_background</item>
        <item name="android:titleTextStyle">@style/TitleText</item>
        <item name="titleTextStyle">@style/TitleText</item>

        <!--
        <item name="android:popupMenuStyle">@style/MyPopupMenu</item>
        <item name="popupMenuStyle">@style/MyPopupMenu</item>

        <item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
        <item name="dropDownListViewStyle">@style/MyDropDownListView</item>

        <item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
        <item name="actionBarTabStyle">@style/MyActionBarTabStyle</item>

        <item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
        <item name="actionDropDownStyle">@style/MyDropDownNav</item>

        <item name="android:listChoiceIndicatorMultiple">@drawable/ad_btn_check_holo_light</item>
        <item name="android:listChoiceIndicatorSingle">@drawable/ad_btn_radio_holo_light</item>

        <item name="android:actionOverflowButtonStyle">@style/MyOverflowButton</item>


        -->
    </style>

    <style name="Widget.Nomad.ActionBar" parent="Widget.Sherlock.ActionBar">
        <item name="android:background">#E5492A</item>
        <item name="background">#E5492A</item>
    </style>

    <style name="TitleText" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
        <item name="android:textColor">@android:color/white</item>
        <item name="textColor">@android:color/white</item>
        <item name="android:textSize">18dip</item>
        <item name="textSize">18dip</item>
    </style>

</resources>
4

2 回答 2

6

我不确定项目背景,但对于文本颜色,您可以:

  • 在 Widget.Nomad.ActionBar 中添加这些项目(带有父 Widget.Sherlock.ActionBar 的样式):

    <item name="android:titleTextStyle">@style/TitleText</item>
    <item name="titleTextStyle">@style/TitleText</item>
    
  • 在哪里:

    <style name="TitleText" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
        <item name="android:textColor">@android:color/white</item>
        <item name="android:textSize">18sp</item>
    </style>
    
于 2012-12-21T11:21:23.750 回答
4

最好的解决方案是这个!

actionBar.setTitle(Html.fromHtml("<font color=\"#ffffff\"><b>" + AppName + "</b></font>"));

我保证这会很有帮助!祝你好运!

于 2014-05-08T02:53:24.220 回答