0

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);
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Soroosh
  • 543
  • 1
  • 4
  • 21
  • 1
    I think Android does not support Gradient Shader for Stroke type style. Check a similar question here. https://stackoverflow.com/questions/20870853/android-shape-border-with-gradient – CodeWithVikas Nov 09 '19 at 17:55
  • In your code you draw stroke only, not a "body". To draw "body" use Style.FILL – Style-7 Nov 09 '19 at 17:58

0 Answers0