I have a custom drawable which I want to make it blink.Currently I can see the drawable being shown next to the text but no blinking affect
public class CustomDrawable extends Drawable {
private Context mContext;
private int mColor;
public CustomDrawable(Context context, int color) {
mContext = context;
mColor = color;
}
@Override
public void draw(Canvas canvas) {
int x = 30;
int y = 30;
int radius = 15;
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(mContext.getResources().getColor(R.color.transparent));
paint.setAntiAlias(true);
canvas.drawPaint(paint);
paint.setColor(mColor);
canvas.drawCircle(x / 2, y / 2, radius, paint);
}
@Override
public void setAlpha(int alpha) {
}
@Override
public void setColorFilter(ColorFilter cf) {
}
@Override
public int getOpacity() {
return 0;
}
}
How can I make the custom drawable so that it blinks I tried changing the alpha but there was no effect on it.
mTextView = (TextView) findViewById(R.id.textView);
AnimationDrawable drwable = new AnimationDrawable();
drwable.addFrame(new CustomDrawable(this, Color.RED), 50);
drwable.setAlpha(255);
drwable.setEnterFadeDuration(500);
mTextView.setCompoundDrawables(null, drwable, null, null);
drwable.start()