Android 在圆弧边缘添加一个圆?

Android 在圆弧边缘添加一个圆?,android,math,view,android-custom-view,geometry,Android,Math,View,Android Custom View,Geometry,如何在圆弧边缘添加小圆。 并且它也应该在时钟方向上与弧边一起移动。 现在,我通过更改扫描角度成功地设置了圆弧动画。 黑点还在 下面是getView和动画类的代码 --- init method and implement constructor ---- mRectF = new RectF(mWidth / 2 - 360, mHeight / 2 - 360, mWidth / 2 + 360, mHeight / 2 + 360); @Override protected void

如何在圆弧边缘添加小圆。
并且它也应该在时钟方向上与弧边一起移动。
现在,我通过更改扫描角度成功地设置了圆弧动画。
黑点还在

下面是getView和动画类的代码

--- init method and implement constructor ----

 mRectF = new RectF(mWidth / 2 - 360, mHeight / 2 - 360, mWidth / 2 + 360, mHeight / 2 + 360);

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    //draw circle background
    mPaint.setColor(getResources().getColor(R.color.timer_background_color));
    canvas.drawCircle(mWidth / 2, mHeight / 2, 360, mPaint);

    mPaint.setColor(getResources().getColor(R.color.actionbar_back_color));
    canvas.drawArc(mRectF, mStartAnagle, mSweepAngle, false, mPaint);
}

public class TimerAnimation extends Animation{

    public TimerAnimation (float startAngle, float sweepAngle, long duration) {
        mStartAnagle = startAngle;
        mSweepAngle = sweepAngle;
        setDuration(duration);
        setRepeatCount(Animation.INFINITE);
        setInterpolator(new LinearInterpolator());
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        if (!isComplete) {
            mSweepAngle = mSweepAngle + 6;
            if (mSweepAngle >= 360) {
                isComplete = true;
                mSweepAngle = 360;
            }
        } else {
            mStartAnagle = mStartAnagle + 6;
            mSweepAngle = mSweepAngle - 6;
            if (mStartAnagle >= 360)
                mStartAnagle = 0;
            if (mStartAnagle == 270 || mSweepAngle <= 0) {
                isComplete = false;
                mSweepAngle = 0;
            }
        }
        invalidate();
    }
}
——初始化方法和实现构造函数----
mRectF=新的RectF(mWidth/2-360,mHeight/2-360,mWidth/2+360,mHeight/2+360);
@凌驾
受保护的void onDraw(画布){
super.onDraw(帆布);
//绘制圆形背景
setColor(getResources().getColor(R.color.timer\u background\u color));
帆布画圈(mWidth/2,mHeight/2,360,mPaint);
setColor(getResources().getColor(R.color.actionbar\u back\u color));
画布绘制弧(mRectF、mStartAnagle、MSweapangle、false、mPaint);
}
公共类TimerAnimation扩展了动画{
公共时间信息(浮动星缠结、浮动扫描角、长持续时间){
mStartAnagle=startAngle;
msweapangle=扫掠角;
设置持续时间(持续时间);
setRepeatCount(Animation.INFINITE);
setInterpolator(新的LinearInterpolator());
}
@凌驾
受保护的无效应用转换(浮点插值时间,转换t){
如果(!isComplete){
msweapangle=msweapangle+6;
如果(msweapangle>=360){
isComplete=true;
msweapangle=360;
}
}否则{
mStartAnagle=mStartAnagle+6;
msweapangle=msweapangle-6;
如果(mStartAnagle>=360)
mStartAnagle=0;

如果(mStartAnagle==270 | | msweapangle可能您应该使用
Path

Path path = new Path();
// Set the starting position of the path to (0,0).
path.moveTo(0, 0);
path.arcTo(...); //draw your arc here
path.circleTo(); //draw a small circle here at the end of arc

也可能您应该将其用作小圆的中心。

步骤1:计算黑点的位置

建议中心位置为(centerX,centerY),黑点位置为(x,y),然后

步骤2:绘制黑点

建议点图像是可绘制的。点

Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.dot) 
                             .copy(Bitmap.Config.ARGB_8888, true);
canvas.drawBitmap(bitmap, x, y, null);

你能告诉我你是如何实现这一点的吗code@mohdkhalidSiddiqui我想在视图中显示3个弧(如生长的三个阶段),当我在弧上滑动时,弧的颜色应该改变,我应该能够从一个弧跳到另一个弧。有解决方案吗?
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.dot) 
                             .copy(Bitmap.Config.ARGB_8888, true);
canvas.drawBitmap(bitmap, x, y, null);