简体   繁体   中英

How to change action bar background color on holding home button?

I had changed Action Bar color with this code: getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0067ad"))); But when I hold Home button there Action Bar Color is Black. How I can change it! Thanks! 在此处输入图片说明

You'd better set color of Actionbar in styles-v21.xml like following:

<item name="android:colorPrimary">@color/yourActionbarColor</item>

colorPrimary determines the color of Actionbar and app's header in recents. In styles.xml focused on pre-L versions, you should use name="colorPrimary" to get same result.

And if you only want to change header color shown in recents above Lollipop, you can use following java code:

TaskDescription taskDesc = new TaskDescription(yourTitle, yourIcon, yourColor);
myActivity.setTaskDescription(taskDesc);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM