Androidメッセージ赤点付きビュー、超簡潔な実装
576 ワード
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.Button;
public class RedButton extends Button {
private Paint paint = new Paint();
public RedButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
paint.setColor(Color.RED);
canvas.drawCircle(getWidth() - 30, 30, 30, paint);
}
}