Как изменить цвет текста названия приложения в AppCompat.Light.DarkActionBar?
Изменить цвет фона проблем не составляет, а вот как изменить цвет текста уже всю голову сломала и весь инет облазила. Как этот текст правильно называется?
<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 шт):
Автор решения: Dareten
→ Ссылка
<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>
Здесь основной цвет и будет отвечать за цвет названия.
Автор решения: Sergei Buvaka
→ Ссылка
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);
