0

anna_prog

Изменить цвет фона проблем не составляет, а вот как изменить цвет текста уже всю голову сломала и весь инет облазила. Как этот текст правильно называется?

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#0380DA</color>
    <color name="colorPrimaryDark">#000000</color>
    <color name="colorAccent">#03DAC5</color>
    <color name="colorTabText">#000000</color>
</resources>

2 ответа 2

2
<style name="ToolBarStyle" parent="Theme.AppCompat">
        <item name="android:textColorPrimary">@color/text_head_color</item>
        <item name="android:textColorSecondary">@color/colorPrimary</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/text_head_color</item>
</style>

Здесь основной цвет и будет отвечать за цвет названия.

1
0

ID заголовка ActionBar скрыт. Это внутренний механизм и доступ к нему не может быть получен обычным путем. Вы можете получить ссылку используя Resources.getIdentifier и после использовать View.findViewById.

int titleId = getResources().getIdentifier("action_bar_title", "id", "android");
Теперь вы можете использовать этот `Id` с `TextView`

TextView abTitle = (TextView) findViewById(titleId);
abTitle.setTextColor(colorId);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.