In this Ariticle helps to create a circle in andriod using
Create a Customized View Class
public class Ball extends View {}
Override the onDraw()
protected void onDraw(Canvas canvas) { }
Create Paint Object for draw the circle
mPaints1 = new Paint();
mPaints2 = new Paint();
mPaints1.setAntiAlias(true);
mPaints1.setStyle(Paint.Style.FILL);
mPaints2 = new Paint(mPaints1);
mPaints2.setColor(Color.BLUE);
mBigOval = new RectF(40, 10, 280, 250);
Draw Circle using drawArc
canvas.drawArc(oval, mStart, mSweep, useCenter, paint);
SourceCode
public class Ball extends View {
private Paint mPaints2;
private Paint mPaints1;
private RectF mBigOval;
private float mStart, mSweep;
private int mBigIndex;
public Ball(Context context) {
super(context);
mPaints1 = new Paint();
mPaints2 = new Paint();
mPaints1.setAntiAlias(true);
mPaints1.setStyle(Paint.Style.FILL);
mPaints2 = new Paint(mPaints1);
mPaints2.setColor(Color.BLUE);
mBigOval = new RectF(40, 10, 280, 250);
}
private void drawArcs(Canvas canvas, RectF oval, boolean useCenter,
Paint paint) {
canvas.drawArc(oval, mStart, mSweep, useCenter, paint);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
drawArcs(canvas, mBigOval, true, mPaints2);
mSweep += 2;
if (mSweep > 360) {
mStart += 10;
if (mStart >= 360) {
mStart -= 360;
}
mBigIndex = (mBigIndex + 1);
}
invalidate();
}
}
Create a Customized View Class
public class Ball extends View {}
Override the onDraw()
protected void onDraw(Canvas canvas) { }
Create Paint Object for draw the circle
mPaints1 = new Paint();
mPaints2 = new Paint();
mPaints1.setAntiAlias(true);
mPaints1.setStyle(Paint.Style.FILL);
mPaints2 = new Paint(mPaints1);
mPaints2.setColor(Color.BLUE);
mBigOval = new RectF(40, 10, 280, 250);
Draw Circle using drawArc
canvas.drawArc(oval, mStart, mSweep, useCenter, paint);
SourceCode
public class Ball extends View {
private Paint mPaints2;
private Paint mPaints1;
private RectF mBigOval;
private float mStart, mSweep;
private int mBigIndex;
public Ball(Context context) {
super(context);
mPaints1 = new Paint();
mPaints2 = new Paint();
mPaints1.setAntiAlias(true);
mPaints1.setStyle(Paint.Style.FILL);
mPaints2 = new Paint(mPaints1);
mPaints2.setColor(Color.BLUE);
mBigOval = new RectF(40, 10, 280, 250);
}
private void drawArcs(Canvas canvas, RectF oval, boolean useCenter,
Paint paint) {
canvas.drawArc(oval, mStart, mSweep, useCenter, paint);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
drawArcs(canvas, mBigOval, true, mPaints2);
mSweep += 2;
if (mSweep > 360) {
mStart += 10;
if (mStart >= 360) {
mStart -= 360;
}
mBigIndex = (mBigIndex + 1);
}
invalidate();
}
}
Thanks for this! :D
ReplyDeleteHello, I enjoy reading your post. I found very unique content at this site. I want to say that after reading this post, I became a big fan of your writing. Thank you so much for sharing this!
ReplyDeleteEsports Tournament App Development
Such a very useful blog. Very interesting to read this blog. I would like to thank you for the efforts you had made for writing this awesome blog.
ReplyDeleteevs full form
raw agent full form
full form of tbh in instagram
dbs bank full form
https full form
tft full form
pco full form
kra full form in hr
tbh full form in instagram story
epc full form