在android上用手指触摸画出一条平滑的线条。 我首先设置了line的属性。 我尝试了很多东西。但仍然没有工作。 我的设备是galaxy note 10.1和G2。
public CanvasClass(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
mPaint = new Paint();
this.mPaint.setColor(Color.BLACK);
this.mPaint.setStrokeWidth(8);
this.mPaint.setAntiAlias(true);
this.mPaint.setDither(true); // enable dithering
this.mPaint.setStyle(Paint.Style.FILL); // set to STOKE
this.mPaint.setStrokeJoin(Paint.Join.ROUND); // set the join to round you want
this.mPaint.setStrokeCap(Paint.Cap.ROUND); // set the paint cap to round too
}
/////////////////////////////////////////////// //////////////////
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
if(!pointList.isEmpty())
for(int i =0; i<pointList.size();i++){
if(!pointList.get(i).getIsDown())
canvas.drawLine(this.pointList.get(i-1).getValueX(), this.pointList.get(i-1).getValueY(), this.pointList.get(i).getValueX(), this.pointList.get(i).getValueY(), this.mPaint);
}
}