Skip to content

Instantly share code, notes, and snippets.

@galaxyfeeder
Last active December 25, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save galaxyfeeder/7026165 to your computer and use it in GitHub Desktop.
Save galaxyfeeder/7026165 to your computer and use it in GitHub Desktop.
public class ColorGradientCircleButton extends View{
private Paint mPaint;
private int width, height;
public ColorGradientCircleButton(Context context) {
super(context);
init();
}
public ColorGradientCircleButton(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ColorGradientCircleButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
mPaint = new Paint();
mPaint.setColor(Color.BLACK);
mPaint.setStrokeWidth(1);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
width = getWidth();
height = getHeight();
canvas.drawCircle(width/2, height/2, height/3, mPaint);
}
public void changeColor(int color){
mPaint.setColor(color);
invalidate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment