Setting header color of app in overview (recent apps) screen
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);
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, 2022Comments
-
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:
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 about 9 yearsTo 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 about 9 yearsWorks nicely. Depending on
minSdkVersion
, may need to be wrapped inif (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ... }
-
user149408 over 8 yearsWorks nicely, once you figure out it won't work in
onCreate()
. Place this code inonResume()
and you're good. -
cherry-wave about 8 yearsIs there a possibility to do this for sdk 19?
-
Dariush Malek about 7 yearsAwesome, in my case i had to put it within the onStart() method to get it work.