0

as the title suggest I'm struggling to change the Textcolor of my Apps name. I've tried various things I found online and in stackoverflow but none of them have worked. Im using Kotlin (just in case it matters) and Android Studio with min SDK of 16. Here is my styles.xml: (as you can see I tried 2 different things i found on stackoverflow but they're not doing anything.

<resources>

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

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:textColorPrimary">@color/titleColor</item>
</style>

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
    <item name="android:textColorPrimary">@color/titleColor</item>
</style>

There surely must be an easy way to somehow access the right property. I also tried to change it programmatically but that didnt work either and somehow made my code go red. As you probably can tell im pretty new to Android Development so I wasn't able to use solutions that worked for Apps built in Java, even though i assumed to converter would get it right for me (unfortunately it didn't)

Here is my Manifest.xml

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Mike_AZ
  • 41
  • 1
  • 8
  • update your question with manifest . – Adnan Abdollah Zaki Apr 07 '20 at 14:45
  • I think we need to see some more code - where are you trying to update the color in your code? – Kristy Welsh Apr 07 '20 at 14:48
  • Try this answer https://stackoverflow.com/a/39545292/5699956 – Atiq Apr 07 '20 at 14:49
  • @KristyWelsh I honestly thought you change the title in the styles.xml; i suppose i need to change it somewhere else. I've also added my manifest in my inital post, if that helps – Mike_AZ Apr 07 '20 at 15:02
  • @AdnanAbdollahZaki I added my manifest as you asked, I presume I have to do something in it if you asked for it? – Mike_AZ Apr 07 '20 at 15:02
  • @Max Thank you for that post, I've tried that as well, the first suggestions is simply all red and as a beginner i don't know what exactly is wrong with it. The second suggestion doesnt do anything, and the third... well where do i put that? – Mike_AZ Apr 07 '20 at 15:07

1 Answers1

0

I didn't test this, but I think you need to create your own ActionBar style to use, and in turn you need to create a TextAppearance style to use in that. So you have a chain of dependent styles, where you replace one component of a parent in each.

<style name="MyTitleTextAppearance" parent="Base.TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">titleColor</item>
</style>

<style name="MyActionBar" parent="Widget.AppCompat.ActionBar.Solid">
    <item name="titleTextStyle">@style/MyTitleTextAppearance</item>
</style>

<style name="AppTheme" parent="Theme.AppCompat">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>
Tenfour04
  • 83,111
  • 11
  • 94
  • 154