Android 5.0: how to change recent apps title color?

為{幸葍}努か 提交于 2019-12-17 07:13:19

问题


I'm using AppCompat and my theme is extending Theme.AppCompat.Light.DarkActionBar.

When in Android 5 Lollipop and I press the recent apps button, my app appears with a dark title instead of a white title in the ActionBar.

When I'm inside the app everything looks fine.

What can I do to change the title color in the recent apps view?

EDIT: just figured out that if I use a darker colorPrimary, the title becomes white. I still need a way to force the white title with the original color.


回答1:


You can't force the text color, it is auto generated (either white/black) based on your colorPrimary color.




回答2:


I also looked into this and the best way I could find was (suggestion from MrEngineer13) setting my recents app color to the 600-value of my primary color:

Bitmap bm = BitmapFactory.decodeResource(getResources(), app_icon);
TaskDescription taskDesc = new TaskDescription(getString(R.string.app_name), bm, getResources().getColor(R.color.primary_600));
MainActivity.setTaskDescription(taskDesc);

If you look closely at the Android 5.0 contacts app, you can see that Google themselves is also doing something similar:

Therefore I believe it is impossible to change the title color yourself, but Android will choose a good one for you. (which will also allow Android to change it for accessibility reasons,...)




回答3:


To change the color/title/icon you just need to use the following:

TaskDescription tDesc = new TaskDescription(mTitle, mIcon, mColor);
MainActivity.setTaskDescription(tDesc);


来源:https://stackoverflow.com/questions/26899820/android-5-0-how-to-change-recent-apps-title-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!