Skip to content

Instantly share code, notes, and snippets.

@sunwicked
Created February 15, 2015 19:32
Show Gist options
  • Save sunwicked/00436948fa89e5a994bb to your computer and use it in GitHub Desktop.
Save sunwicked/00436948fa89e5a994bb to your computer and use it in GitHub Desktop.
Using color Tint
public static void tintAndSetCompoundDrawable (Context context,
@DrawableRes int drawableRes, int color, TextView textview) {
Resources res = context.getResources();
int padding = (int) res.getDimension(
R.dimen.activity_horizontal_margin);
Drawable drawable = res.getDrawable(drawableRes);
drawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
textview.setCompoundDrawablesRelativeWithIntrinsicBounds(
drawable, null, null, null);
textview.setCompoundDrawablePadding(padding);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment