Last active
December 25, 2015 19:09
-
-
Save galaxyfeeder/7026165 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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