Android的油漆笔画宽度定位笔画、宽度、油漆、Android

2023-09-04 03:31:01 作者:內些過往的曾經

鉴于这种code画一条线:

Given this code to draw a line:

Paint p;

p = new Paint(Paint.ANTI_ALIAS_FLAG);
p.setColor(android.graphics.Color.WHITE);
p.setStyle(Paint.Style.FILL);
p.setStrokeWidth(21);

canvas.drawLine(0,50,100,50,p);

有3种可能的行:

在内部:该生产线是画在矩形(0,50,100,70) 中心:该生产线是画在矩形(0,40,100,60) 外:该生产线是画在矩形(0,30,100,50)

我看到在实践中居中模式。

What I see in practice is centered mode.

是否有可能控制笔划宽度是如何绘(内部,外部,中心)?

推荐答案

没有你不行;斯托克始终集中。 你可以CONTROLE唯一的事情是: - 行程米特:http://developer.android.com/reference/android/graphics/Paint.html#getStrokeMiter() - 行程上限:http://developer.android.com/reference/android/graphics/Paint.html#getStrokeCap() - 行程加入:http://developer.android.com/reference/android/graphics/Paint.html#getStrokeJoin() - 笔划宽度:http://developer.android.com/reference/android/graphics/Paint.html#getStrokeWidth()

No you can't; the stoke is always centered. The only things you can controle are : - stroke mitter : http://developer.android.com/reference/android/graphics/Paint.html#getStrokeMiter() - stroke cap : http://developer.android.com/reference/android/graphics/Paint.html#getStrokeCap() - stroke join : http://developer.android.com/reference/android/graphics/Paint.html#getStrokeJoin() - stroke width : http://developer.android.com/reference/android/graphics/Paint.html#getStrokeWidth()

在你的情况,你必须根据你的行程需要precalculate所需的宽度和高度

in your case, you must precalculate the desired width and height according to your stroke requirement