O
O
Oleksiy2015-12-19 18:30:17
Android
Oleksiy, 2015-12-19 18:30:17

How to set different text color in actionbar title and tab?

I'm trying to set the colors I need through styles and colors.

<style name="AppTheme" parent="MyTheme.Base">
    </style>

    <style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

<resources>
    <color name="colorPrimary">#FFFFB007</color>///цвет фона actionBar
    <color name="colorPrimaryDark">#093948</color>///цвет фона statusBar
    <color name="colorAccent">#FFFFB007</color>///цвет подчерка активного таба
    <color name="secondary_text_default_material_dark">#7c7c7c</color>///цвет текста пассивного таба
    <color name="text_frame">#093948</color>///цвет текста во фрагментах
</resources>

At the output we have:
16a3ad710af74efcba02d9a31680cfaf.png355eb696c7c84510a87bdba76c699cdc.png
As a result, we ran into a dead end. How can I set different colors for titla (#fff) and active tab (#000)?
PS Tried
<color name="primary_text_default_material_dark">#fff</color>

But this sets the same text color for: actionBar and active tab.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleksiy, 2015-12-19
@xox_ua

As an option:
1. Add this to colors -

<color name="primary_text_default_material_dark">#093948</color>

2. In activity we write:
getSupportActionBar().setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.app_name) + "</font>"));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question