Draw a line with curved edges in Android

牧云@^-^@ 提交于 2020-01-01 08:43:58

问题


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 is appreciated. Thank you


回答1:


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.



来源:https://stackoverflow.com/questions/20822977/draw-a-line-with-curved-edges-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!