Changing Android app's status bar color but keep translucency -


for app i'm building, used design support library. created app uses tablayout. little feature of app when user changes tabs, color of both tablayout , toolbar change corresponding color. we're using new navigationview, present user material design drawerlayout.

however, changing color of both tablayout , toolbar no problem @ all, in lines of following;

string hexcolor = string.format("#%06x", (0xffffff & getresources().getcolor(r.color.primarycolor))); getbaseactivity().getsupportactionbar().setbackgrounddrawable(new colordrawable(color.parsecolor(hexcolor))); mtablayout.setbackgroundcolor(getresources().getcolor(primarycolor)); 

this good, , working it's supposed to. problem appears when try set status bar background. since material design specification tells navigationdrawer should special treatment, below image shows how status bar form of translucent. navigation drawer falls on main fragment while navigation bar above both, being translucent bar.

what should like

my first thoughts it's bar #7000 hexadecimal value or something, couldn't further truth. doing doesn't change color of actual color should "darken".

after tried setting darker version of required color background status bar so;

if (build.version.sdk_int >= build.version_codes.lollipop) {     window window = getbaseactivity().getwindow();     window.addflags(windowmanager.layoutparams.flag_draws_system_bar_backgrounds);     window.setstatusbarcolor(getresources().getcolor(r.color.primarycolor)); } 

but after doing this, complete functionality breaks. view this:

enter image description here

in essence, can fix behaviour? i'd change translucency feature still needs according material design spec, change status bar's background color.

i think there translucent shadow behind , can not remove it. can try play around colors alpha channel achieve acceptable result or think workaround solution this: far see want status bar color different when navigation drawer open, right? why not adding empty view desired color , same height statusbar in navigationdrawer layout achieve same effect?

btw, there r.dimen.status_bar_height height specification.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -