Setting header color of app in overview (recent apps) screen

13,988

You can change this via ActivityManager.TaskDescription:

https://developer.android.com/reference/android/app/ActivityManager.TaskDescription.html

From an Activity context, call:

TaskDescription taskDescription = new TaskDescription(label, icon, colorPrimary);
((Activity)this).setTaskDescription(taskDescription);
Share:
13,988
MaciejGórski
Author by

MaciejGórski

"This is programming, anything is possible" Developer of Vielen Games - turn-based multiplayer game server (quoridor) Hrisey - boilerplate removal tool for Android, Android Maps Extensions - marker clustering with smooth API, Yafi - Internet Chess - app with ugly or no design and a lot of apps for many clients.

Updated on June 03, 2022

Comments

  • MaciejGórski
    MaciejGórski about 2 years

    I'm adding some Lollipop-only styling to an app.

    I want to change color of header in overview screeen like Gmail here:
    enter image description here

    I have figured out I can do

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    
        <item name="android:colorPrimary">@color/my_favorite_color</item>
    
    </style>
    

    to achieve it, but I would want to specify only the color for this case, just like I can do:

    <item name="android:statusBarColor">@color/my_favorite_color<item>
    

    Is there a specific attribute to set header's color?

    Side question: can icon and title be also changed?

  • milosmns
    milosmns about 9 years
    To clarify more: * Label - text on the card header * Icon - left bitmap icon (usually an icon which looks good on the 'colorPrimary' color * colorPrimary - the card header color (usually same as the Toolbar color, but not necessarily) This solution worked for me, +1 :)
  • Jonik
    Jonik about 9 years
    Works nicely. Depending on minSdkVersion, may need to be wrapped in if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ... }
  • user149408
    user149408 over 8 years
    Works nicely, once you figure out it won't work in onCreate(). Place this code in onResume() and you're good.
  • cherry-wave
    cherry-wave about 8 years
    Is there a possibility to do this for sdk 19?
  • Dariush Malek
    Dariush Malek about 7 years
    Awesome, in my case i had to put it within the onStart() method to get it work.