How to change shade of color dynamically android? -
i'm using palette class programmatically dominant color image want use status bar , toolbar. according material design guidelines, status bar color should 2 shades darker toolbar color.
bitmap bitmap = ((bitmapdrawable) ((imageview)mimageview).getdrawable()).getbitmap(); if (bitmap != null) { palette = palette.generate(bitmap); vibrantswatch = palette.getvibrantswatch(); darkvibrantswatch = palette.getdarkvibrantswatch(); }
for darker color i'm using darkvibrantswatch , lighter color, i'm using vibrantswatch. in of cases, these turn out different each other , hence becoming unusable. there workaround this? maybe if possible 1 color, darkvibrantswatch, , programmatically generate color 2 shades lighter?
i'm not sure getting 2 shades lighter can play around shade_factor , see if can achieve want.
private int getdarkershade(int color) { return color.rgb((int)(shade_factor * color.red(color)), (int)(shade_factor * color.green(color)), (int)(shade_factor * color.blue(color))); }
code snippet taken here
Comments
Post a Comment