Seyyed Mahmood Ahmadi Seyyed Mahmood Ahmadi - 1 year ago 104
Android Question

How to change background color of action bar without increasing min sdk?

As we know, a colored background of action bar permitted in sdk level 11. But there are some applications with colored action bar that have min sdk lower than 11. For example Whatsapp has green action bar but has min sdk:7 WhatsApp FAQ, or the Telegram application has min sdk:8 Telegram FAQ, but has blue action bar.

How these applications work? And how I can do this?

Answer Source

the Toolbar (new name for the ActionBar introduced in Lollipop) is just a normal View.


you just set it's background like any other view.

// java
toolbar.setBackgroundColor(int color);
// or 
toolbar.setBackgroundResource(int resId);

// or XML
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download