Change Actionbar title color

Asked

Viewed 5,728 times

0

This is my new layout, but the overflow items were blank with white background, and I need white background with black letters. Remembering that I used stylegenerator.

<style name="Theme.Datalayer" parent="@android:style/Theme.Holo.Light.DarkActionBar">
    <item name="android:actionBarItemBackground">@drawable/selectable_background_datalayer</item>
    <item name="android:popupMenuStyle">@style/PopupMenu.Datalayer</item>
    <item name="android:dropDownListViewStyle">@style/DropDownListView.Datalayer</item>
    <item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Datalayer</item>
    <item name="android:actionDropDownStyle">@style/DropDownNav.Datalayer</item>
    <item name="android:actionBarStyle">@style/ActionBar.Solid.Datalayer</item>
    <item name="android:actionModeBackground">@drawable/cab_background_top_datalayer</item>
    <item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_datalayer</item>
    <item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Datalayer</item>
   <item name="android:actionMenuTextColor">@color/black</item>
    <!-- Light.DarkActionBar specific -->
    <item name="android:actionBarWidgetTheme">@style/Theme.Datalayer.Widget</item>
</style>

<style name="ActionBar.Solid.Datalayer" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@drawable/ab_solid_datalayer</item>
    <item name="android:backgroundStacked">@drawable/ab_stacked_solid_datalayer</item>
    <item name="android:backgroundSplit">@drawable/ab_bottom_solid_datalayer</item>
    <item name="android:progressBarStyle">@style/ProgressBar.Datalayer</item>
</style>

<style name="ActionBar.Transparent.Datalayer" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/ab_transparent_datalayer</item>
    <item name="android:progressBarStyle">@style/ProgressBar.Datalayer</item>
</style>

<style name="PopupMenu.Datalayer" parent="@android:style/Widget.Holo.ListPopupWindow">
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_datalayer</item>
    <item name="android:textColor">@color/black</item>
</style>

<style name="DropDownListView.Datalayer" parent="@android:style/Widget.Holo.ListView.DropDown">
    <item name="android:listSelector">@drawable/selectable_background_datalayer</item>
</style>

<style name="ActionBarTabStyle.Datalayer" parent="@android:style/Widget.Holo.ActionBar.TabView">
    <item name="android:background">@drawable/tab_indicator_ab_datalayer</item>
</style>

<style name="DropDownNav.Datalayer" parent="@android:style/Widget.Holo.Spinner">
    <item name="android:background">@drawable/spinner_background_ab_datalayer</item>
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_datalayer</item>
    <item name="android:dropDownSelector">@drawable/selectable_background_datalayer</item>
    <item name="android:spinnerDropDownItemStyle">@style/mySpinnerItemStyle</item>
</style>

<style name="mySpinnerItemStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
    <item name="android:textColor">@color/black</item>
</style>

<style name="ProgressBar.Datalayer" parent="@android:style/Widget.Holo.ProgressBar.Horizontal">
    <item name="android:progressDrawable">@drawable/progress_horizontal_datalayer</item>
</style>

<style name="ActionButton.CloseMode.Datalayer" parent="@android:style/Widget.Holo.ActionButton.CloseMode">
    <item name="android:background">@drawable/btn_cab_done_datalayer</item>
</style>

<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Datalayer.Widget" parent="@android:style/Theme.Holo">
    <item name="android:popupMenuStyle">@style/PopupMenu.Datalayer</item>
    <item name="android:dropDownListViewStyle">@style/DropDownListView.Datalayer</item>
</style>

2 answers

1

To solve the problem completely with the use of the Actionbar Style Generator, the Base Theme as Light - Dark Action Bar and above the theme you are using. Thus the styles of the elements of the ActionBar will be homogeneous and there will be no more problems.

As a way to stylize some items punctually, as the icon of Overflow Menu and the style of the title and sub-title of the ActionBar recommend the styles below.

To change the drawable relating to Overflow Menu, just add this style rule to your theme:

<style name="Theme.Datalayer" parent="@android:style/Theme.Holo.Light">
    <!-- Demais regras omitidas -->

    <!-- SDK 14+ -->
    <item name="android:actionOverflowButtonStyle">@style/Theme.Datalayer.OverFlow</item>
    <!-- Se usar alguma impl. de actionbar de compatibilidade. e.g: AppCompat
    <item name="actionOverflowButtonStyle">@style/Theme.Datalayer.OverFlow</item>
</style>

<style name="Theme.Datalayer.OverFlow" parent="@android:style/Widget.Holo.Light.ActionButton.Overflow">
    <item name="android:src">@drawable/seu_drawable</item>
</style>

Browse to generate icons from Android Asset Studio - Icon Generator of Roman Nurik or shreyasachar with updated Material Design icons.

To change the title is simpler because it is already resetting the title style, just change the color. Change your style MyTheme.ActionBar.TitleTextStyle thus:

<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <!-- Altere a cor abaixo -->
    <item name="android:textColor">@color/action_bar_text</item>
    <!-- Altere a cor abaixo, acredito que essa regra nao eh necessaria -->
    <item name="android:actionMenuTextColor">@color/action_bar_text</item>
    <!-- Altere a cor abaixo, acredito que essa regra nao eh necessaria -->
    <item name="android:titleTextStyle">@color/action_bar_text</item>
</style>

Still need to change the subtitle color if you need: Ai will have to do similarly to the style of the title:

<style name="Theme.Datalayer" parent="@android:style/Theme.Holo.Light">
    <!-- Demais regras omitidas -->
    <!-- Acrescente a regra abaixo -->
    <item name="android:subtitleTextStyle">@style/MyTheme.ActionBar.SubTitleTextStyle</item>
</style>

<!-- Crie este estilo -->
<style name="MyTheme.ActionBar.SubTitleTextStyle" parent="@android:style/TextAppearance.TextAppearance.Holo.Widget.ActionBar.Subtitle">
    <!-- Altere a cor abaixo -->
    <item name="android:textColor">@color/action_bar_text</item>
    <!-- Altere a cor abaixo, acredito que essa regra nao eh necessaria -->
    <item name="android:actionMenuTextColor">@color/action_bar_text</item>
    <!-- Altere a cor abaixo, acredito que essa regra nao eh necessaria -->
    <item name="android:subtitleTextStyle">@color/action_bar_text</item>
</style>
  • This is because I used the style Generator. I will try your tips, thank you very much

  • I believe you used this style Generator ( http://jgilfelt.github.io/android-actionbarstylegenerator/), it has a Combobox de Base Theme, check the option Light - Dark Action Bar. I believe it’s the best solution if it’s not causing problems.

  • Solved the title and verflow, but my background of the popup is white, so I return the question...now change the color of the popup letter

  • Popup would be the Dialog? This style changed the title color of the Dialog?

  • the text color of overflow items

  • @Juliana I tried to find the style of the item of the Popupmenu items but I did not find it. I strongly recommend that you generate your style again using the DarkActionBar, so it becomes homogeneous the theme. I think that changing one or the other punctually will not solve the problem completely.

Show 1 more comment

0

Solved! Follows xml change:

@drawable/selectable_background_datalayer @style/Popupmenu.Datalayer @style/Dropdownlistview.Datalayer @style/Actionbartabstyle.Datalayer @style/Dropdownnav.Datalayer @style/Actionbar.Solid.Datalayer @drawable/cab_background_top_datalayer @drawable/cab_background_bottom_datalayer @style/Actionbutton.CloseMode.Datalayer @color/black @style/Theme.Datalayer.Widget @style/Textappearance

<style name="TextAppearance">
    <item name="android:textColor">@android:color/black</item>
</style>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.