How to draw smooth / rounded path?

I am creating Paths and adding multi lines in each path by using path.moveTo(x, y) and path.lineTo(x, y). Then canvas.drawPath(path, paint) is drawing all paths. But there are 1-2 pixel space between lines in some paths. How can I remove these spaces? My code is something like that:

paint = new Paint();

for (int i = 0; i < length; i++) {
     Path path = new Path();
     path.moveTo(a, b);
     path.lineTo(c, d);
     path.moveTo(c, d);
     path.lineTo(e, f);
     canvas.drawPath(path, paint);

  • developing an android lock screen application
  • How to close Android application?
  • Google Cloud Messaging in Delphi XE5?
  • Android: converting between Strings, SpannedStrings and Spannablestrings
  • Sharing via Seekable Pipe or Stream with Another Android App?
  • RXJava - make a pausable observable (with buffer and window for example)
  • What to do about curl clone.bundle error on AOSP repo sync
  • How to change color and font on ListView
  • Android GCM (push notification): device doesn't receive notification if application is stopped
  • Should Java finalizer really be avoided also for native peer objects lifecycle management?
  • How can I switch between two fragments, without recreating the fragments each time?
  • How to convert 24 hr format time in to 12 hr Format?
  • 2 Solutions collect form web for “How to draw smooth / rounded path?”

    Maybe this will create what you want

    paint.setColor(color);                    // set the color
    paint.setStrokeWidth(size);               // set the size
    paint.setDither(true);                    // set the dither to true
    paint.setStyle(Paint.Style.STROKE);       // set to STOKE
    paint.setStrokeJoin(Paint.Join.ROUND);    // set the join to round you want
    paint.setStrokeCap(Paint.Cap.ROUND);      // set the paint cap to round too
    paint.setPathEffect(new CornerPathEffect(10) );   // set the path effect when they join.
    paint.setAntiAlias(true);                         // set anti alias so it smooths


    You probably don’t want to lineTo(c, d) and then immediately moveTo(c, d) which is the same point. If you do this, you won’t get a nice corner join on the two line segments, which may look like an ugly gap.

    Try removing that moveTo.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.