0
我有一個自定義繪製的,我希望把它blink.Currently我可以看到旁邊的文本顯示的可繪製的幸福,但沒有閃爍影響創建自定義繪製閃爍
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;
}
}
如何我可以使自定義可繪製,使其閃爍我試着改變alpha,但沒有影響。
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()
http://stackoverflow.com/questions/28806879/animating-drawable-alpha-property –