Canvas(modifier = Modifier.fillMaxSize()) {
// Fetching width and height for
// setting start x and end y
val canvasHeight = size.height
// drawing a line between start(x,y) and end(x,y)
drawLine(
start = Offset(x = 0f, y = 0.12f * canvasHeight),
end = Offset(x = 0f, y =0.5f *canvasHeight),
color = Color.Red,
strokeWidth = 10F,
cap = StrokeCap.Round
)
}
path = new Path();
path.moveTo(50, 50);
path.lineTo(50, 500);
path.lineTo(200, 500);
path.lineTo(200, 300);
path.lineTo(350, 300);
float radius = 50.0f;
CornerPathEffect cornerPathEffect = new CornerPathEffect(radius);
paint.setPathEffect(cornerPathEffect);
// this setPathEffect will set the curve edges for every new joining
canvas.drawPath(path, paint);
4条答案
按热度按时间xyhw6mcr1#
使用
Paint.setStrokeCap()
方法您需要Paint.Cap.ROUND
。默认值为Paint.Cap.BUTT
。有一个类似的Path
属性,称为路径连接。它决定如何绘制路径的组成部分的部分。使用Path.setPathJoin()
进行设置。你将来可能需要它。祝你好运xoefb8l82#
您可以在下面使用
m1m5dgzv3#
这是针对KotlinJetpack Compose用户的:使用cap属性
oxosxuxt4#
通过此链接,This Link will teach you proper usages