wnafee / vector-compat

A support library for VectorDrawable and AnimatedVectorDrawable classes introduced in Lollipop
1.23k stars 161 forks source link

Add setColorFilter method to MorphButton. #4

Closed ahmedre closed 9 years ago

ahmedre commented 9 years ago

VectorDrawable and AnimatedVectorDrawable both support setColorFilter, but there's no easy way to apply the color filter to a MorphButton. This adds a method which proxies the setColorFilter calls to the respective drawables if they are set.

wnafee commented 9 years ago

In the latest commit I pushed there is now full tinting support. You can apply tint in one of 2 ways:

  1. In your layout xml: Just add app:backgroundTint to MorphButton. This takes either a color ( eg. "#1E5FD6") or a color state list (defined in xml)
  2. In your java code. You can do something like this:
//Assume you have a properly defined MorphButton
myMorphButton.setBackgroundTintList(ColorStateList.valueOf(Color.RED));

There is now also a setColorFilter() method for fallback to drawables that still don't support tint but the implementation already takes care of this fallback for you, so it's best to just use setBackgroundTintList()

ahmedre commented 9 years ago

thanks @wnafee!