Guys i have a textview which i need it to be blinking please help me with it.
public final class BlinkEffectUtils {
private static BlinkEffectUtils blinkEffect;
public enum PROPERTY_TYPE {
BACKGROUND_COLOR,
TEXT_COLOR
}
private BlinkEffectUtils() {
}
public static BlinkEffectUtils getInstance(Context context) {
if (blinkEffect == null) {
blinkEffect = new BlinkEffectUtils();
}
return blinkEffect;
}
public void setBlinkEffect(Object targetView, PROPERTY_TYPE property_type, int duration, int defaultColor, int effectColor) {
String propertyName = "";
switch (property_type) {
case TEXT_COLOR:
propertyName = "textColor";
break;
case BACKGROUND_COLOR:
propertyName = "backgroundColor";
break;
}
@SuppressLint("ObjectAnimatorBinding")
ObjectAnimator anim = ObjectAnimator.ofInt(targetView, propertyName,
effectColor,
defaultColor);
anim.setDuration(duration);
anim.setEvaluator(new ArgbEvaluator());
anim.setRepeatMode(ValueAnimator.REVERSE);
anim.setRepeatCount(ValueAnimator.INFINITE);
anim.start();
}
}