Android 5.0: how to change recent apps title color?

Colouring a Cordova app’s title bar in Android 5’s recent apps, with a theme and a colour.

From the archive. First published on the Programming Recipes blog on 13 February 2016. Kept as it was written, so details may have moved on since.

OriginalArchived copy

I build android apps using Cordova and it is great. I wanted to change the Title color bar when you view you resent apps on android 5.

I spend quite some time trying to figure this out as I know little about the android development ways but always keen to learn so this is how I managed it:

Under your platforms > android > res folder add a new “values-v14” folder. Add a themes.xml file to the folder:

themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<!-- Any customizations for your app running on 4.0+ devices here -->
<item name="android:colorPrimary">@color/custom_colorPrimary</item>
</style>
</resources>

Now add your colors.xml under your values folder:

colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="custom_colorPrimary">#4FC1C1</color>
</resources>

Now go to your AndroidManifest.xml file located under the platforms > android folder and change the android:theme attribute to android:theme="@style/MyAppTheme" :

AndroidManifest.xml
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.cordova.hellocordova" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@style/MyAppTheme" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
</manifest>

Run the cordova CLI: $ cordova run Android

And awesome we have a custom colored title.