Created
February 15, 2015 19:32
-
-
Save sunwicked/00436948fa89e5a994bb to your computer and use it in GitHub Desktop.
Using color Tint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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