Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Actionbar text color using Material Design?

I am using Material Design in my Android app and I want to change Actionbar text color and back button color.

This code is not working:

    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowContentOverlay">@null</item>
    <!--<item name="android:textSize">3sp</item>-->
    <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>

</style>

<style name="MyTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>

<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/titleColor</item>
</style>
like image 286
Besart Avatar asked Dec 31 '22 22:12

Besart


1 Answers

Using the ActionBar in your theme you can use:

 <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <item name="actionBarTheme">@style/ThemeOverlay.Actionbar</item>
 </style>

 <style name="ThemeOverlay.Actionbar" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" >
        <item name="android:textColorPrimary">@color/....</item>
 </style>

enter image description here

like image 176
Gabriele Mariotti Avatar answered Jan 13 '23 14:01

Gabriele Mariotti