android - How to make the title bar change color when the tab is changed -


if on tab in tabbed activity, , change tabs, how make title bar , tab indicator change colors? example of i'm talking can seen below (done on paint).

app bar changing color when different tabs selected figure manipulating different elements , color resources use done change uniformly, @ same time, don't know how that. have 4 tabs, , 4 sets of colors picked material design library, red, blue, green , yellow. including red dark, blue dark, etc.

i'm not using default tab layout activity comes android studio, instead, using 1 similar 1 used here

https://androidbelieve.com/navigation-drawer-with-swipe-tabs-using-design-support-library/

minus navigation drawer. sincerely appreciated, though i'm afraid i'm still quite beginner appreciate if make simple possible.

:d

you can right code according selected tab position tab 1

getsupportactionbar().setbackgrounddrawable(new colordrawable(color.parsecolor("#f00"))); 

for tab 2

getsupportactionbar().setbackgrounddrawable(new colordrawable(color.parsecolor("#ff0"))); 

for tab 3

getsupportactionbar().setbackgrounddrawable(new colordrawable(color.parsecolor("#f0f"))); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -