How to apply radialGradient on stroke of arc in a canvas

235 Views Asked by At

I'm drawing arc with canvas.drawArc(...) and use below code to add gradient to paint object but the gradient just applied on the body of arc and not the stroke. how to draw a gradient stroke?

        paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth((float) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources().getDisplayMetrics()));
        paint.setShader(new RadialGradient(getWidth()/2,getHeight()/2,mRadius/2,Color.BLUE,Color.YELLOW, Shader.TileMode.CLAMP));
        canvas.drawArc(new RectF(getWidth()/2-mRadius, getHeight()/2-mRadius, getWidth()/2+mRadius, getHeight()/2+mRadius),270f,mProgressDegree,true,paint);
0

There are 0 best solutions below