Android的油漆笔画宽度定位 [英] Android Paint stroke width positioning

查看:170
本文介绍了Android的油漆笔画宽度定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于这种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唯一的事情是:
- 行程米特:<一href="http://developer.android.com/reference/android/graphics/Paint.html#getStrokeMiter()">http://developer.android.com/reference/android/graphics/Paint.html#getStrokeMiter()
- 行程上限:<一href="http://developer.android.com/reference/android/graphics/Paint.html#getStrokeCap()">http://developer.android.com/reference/android/graphics/Paint.html#getStrokeCap()
- 行程加入:<一href="http://developer.android.com/reference/android/graphics/Paint.html#getStrokeJoin()">http://developer.android.com/reference/android/graphics/Paint.html#getStrokeJoin()
- 笔划宽度:<一href="http://developer.android.com/reference/android/graphics/Paint.html#getStrokeWidth()">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

这篇关于Android的油漆笔画宽度定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆