diff options
Diffstat (limited to 'core/java/android/widget/ImageView.java')
-rw-r--r-- | core/java/android/widget/ImageView.java | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index e97177d..0881f3e 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -168,10 +168,11 @@ public class ImageView extends View { setScaleType(sScaleTypeArray[index]); } + mDrawableTintMode = Drawable.parseTintMode(a.getInt( + R.styleable.ImageView_tintMode, -1), mDrawableTintMode); + if (a.hasValue(R.styleable.ImageView_tint)) { mDrawableTint = a.getColorStateList(R.styleable.ImageView_tint); - mDrawableTintMode = Drawable.parseTintMode(a.getInt( - R.styleable.ImageView_tintMode, -1), mDrawableTintMode); mHasDrawableTint = true; applyDrawableTint(); @@ -448,50 +449,30 @@ public class ImageView extends View { } /** - * Applies a tint to the image drawable. + * Applies a tint to the image drawable. Does not modify the current tint + * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * <p> * Subsequent calls to {@link #setImageDrawable(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using * {@link Drawable#setTint(ColorStateList, PorterDuff.Mode)}. * * @param tint the tint to apply, may be {@code null} to clear tint - * @param tintMode the blending mode used to apply the tint, may be - * {@code null} to clear tint * * @attr ref android.R.styleable#ImageView_tint - * @attr ref android.R.styleable#ImageView_tintMode + * @see #getTint() * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) */ - private void setTint(@Nullable ColorStateList tint, - @Nullable PorterDuff.Mode tintMode) { + public void setTint(@Nullable ColorStateList tint) { mDrawableTint = tint; - mDrawableTintMode = tintMode; mHasDrawableTint = true; applyDrawableTint(); } /** - * Applies a tint to the image drawable. Does not modify the current tint - * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. - * <p> - * Subsequent calls to {@link #setImageDrawable(Drawable)} will automatically - * mutate the drawable and apply the specified tint and tint mode using - * {@link Drawable#setTint(ColorStateList, PorterDuff.Mode)}. - * - * @param tint the tint to apply, may be {@code null} to clear tint - * - * @attr ref android.R.styleable#ImageView_tint - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) - */ - public void setTint(@Nullable ColorStateList tint) { - setTint(tint, mDrawableTintMode); - } - - /** * @return the tint applied to the image drawable * @attr ref android.R.styleable#ImageView_tint - * @see #setTint(ColorStateList, PorterDuff.Mode) + * @see #setTint(ColorStateList) */ @Nullable public ColorStateList getTint() { @@ -506,16 +487,19 @@ public class ImageView extends View { * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint * @attr ref android.R.styleable#ImageView_tintMode - * @see #setTint(ColorStateList) + * @see #getTintMode() + * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) */ public void setTintMode(@Nullable PorterDuff.Mode tintMode) { - setTint(mDrawableTint, tintMode); + mDrawableTintMode = tintMode; + + applyDrawableTint(); } /** * @return the blending mode used to apply the tint to the image drawable * @attr ref android.R.styleable#ImageView_tintMode - * @see #setTint(ColorStateList, PorterDuff.Mode) + * @see #setTintMode(PorterDuff.Mode) */ @Nullable public PorterDuff.Mode getTintMode() { |