Android怎么画线?

时间:2011-08-18 15:06:36

标签: android android-canvas

  

可能重复:
  How do you set a line's width when drawing in Android?

我见过How to draw a line in android但是如何设置线宽?我试着设置Paint

    colorCenter = new Paint();
    colorCenter.setAntiAlias(true);
    colorCenter.setStrokeWidth(100);
    colorCenter.setColor(0xFF00FFFF);

然后在onDraw()

canvas.drawLine(0, 0, 40, 40, colorCenter);

但总是1px。

我还尝试找到课程LineShape并将其与ShapeDrawable一起使用,但没有这样的课程!

2 个答案:

答案 0 :(得分:0)

获取Canvas并使用drawLine(startX,startY,stopX,stopY,paint)

答案 1 :(得分:0)

...添加..

  colorCenter.setStyle(Paint.Style.STROKE);