简体   繁体   中英

Draw a line with curved edges in Android

I am using canvas.drawLine to draw some line in android but the lines are too sharp but i need a curved edges在此处输入图像描述

Here the 1 is what i have and 2 is what i want to achieve, means a line with curved edges rather than straight edges

How can I achieve that ??

EDIT 2:

I am trying to use the Canvas object to to draw a line. but the lines have a sharp edge, I need a rounded off edge I am using the Paint object

mPaint = new Paint();
mPaint.setColor(Color.BLACK)

Any help would be appreciated great.

Use the Paint.setStrokeCap() method. You need Paint.Cap.ROUND . The default one is Paint.Cap.BUTT . There is a similar Path property that is called path join. It determines how to draw the parts of the path where it's constituent segments join. To set it use Path.setPathJoin() . You might need it in the future. Good luck.

你可以在下面使用

pitchPaint.setStrokeCap(Paint.Cap.ROUND)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM