在概述(最近的应用程序)屏幕中设置应用程序的标题颜色

问题描述:

我正在向应用程序添加一些仅棒棒糖风格.

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

我想在此处更改Gmail概述屏幕中标题的颜色:

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

我已经知道我能做到

<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?

您可以通过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);