Android ListView background color change -


i have listview , want change active row different color.

currently have this:

rowview.setbackgroundcolor( 0xff0000ff ); // make blue bg 

and works expected.

however there 1 "philosophical" problem - since use default color schemes, color should use? blue poor example, because android scheme may dark or light or custom.

things have in mind inverse color, sightly similar color (say 20% darker) or same color, effect.

must work on android 2.2+

edited:

solution looking more this:

int x = this.getresources().getcolor(android.r.color.holo_blue_bright); listviewitem.setbackgroundcolor(x); 

if know color can try

    colordrawable buttoncolor = (colordrawable) button.getbackground(); 

and if you're on android 3.0+ can out resource id of color.

    int colorid = buttoncolor.getcolor(); 

then, following:

    int red = color.red(colorid);     int blue = color.blue(colorid);     int green = color.green(colorid);     double percent = 400;     button.setbackgroundcolor(color.rgb((int)(red * percent/100),         (int)(blue * percent/100),(int)(green * percent/100))); 

note making color higher brightens color, , lower number darkens color.


Comments