0
這是的onDraw方法我:DrawLine的功能改變了我行的顏色,當它不應該
protected void onDraw(Canvas canvas) {
canvas.drawBitmap(bitmap, 0, 0, mBitmapPaint); // Deseneaza Bitmapul mutabil
if (shapes.size() > 0) {
for (ShapeFromLines shapesfromline : shapes) {
if (shapesfromline.size() > 1) {
LogService.log("", "shapes: " + shapesfromline.size());
float startx, starty;
startx = shapesfromline.get(0).stopX;
starty = shapesfromline.get(0).stopY;
for (int i = 1; i < shapesfromline.size(); i++) {
LogService.log("", "----size color in ondraw: " + shapesfromline.get(i).getPaint().getColor());
canvas.drawLine(startx, starty, shapesfromline.get(i).getStopX(), shapesfromline.get(i).stopY, shapesfromline.get(i).getPaint());
LogService.log("", "shapes: drawn");
startx = shapesfromline.get(i).stopX;
starty = shapesfromline.get(i).stopY;
}
}
}
}
for (int i = 0; i < bitmaps.size(); i++) {
if ((bitmaps.get(i).bitmap != null)) {
canvas.save();
canvas.rotate(bitmaps.get(i).rectrotateVal, bitmaps.get(i).pX + (bitmaps.get(i).bitmap.getWidth()/2), bitmaps.get(i).pY + (bitmaps.get(i).bitmap.getHeight()/2));
mBitmapPaint.setAlpha(bitmaps.get(i).alpha);
// canvas.drawRect(bitmaps.get(i).rect, cPaint);
canvas.drawBitmap(bitmaps.get(i).bitmap, bitmaps.get(i).pX, bitmaps.get(i).pY, mBitmapPaint);
canvas.restore();
}
}
mBitmapPaint.setAlpha(255);
canvas.drawPath(mPath, paint);
}
}
正如你可以II有一定的形狀(每個形狀是從點名爲ShapesFromLines的ArrayList創建。現在我的形狀的第一個點是touchDown(ontouchevent),在那裏我保存當前的位置,然後其他點在觸摸時保存。當你第一次按屏幕畫一個點時,第二個點時間,它會連接這2點,然後3,等我保存每個點上的X,Y和塗料 正如你所看到的,我有一個繪製日誌服務,它返回這些點的繪畫值。具有改變顏色選擇器的功能當前路徑的顏色。但是這個設法改變了我所有直線的顏色。現在我檢查了一下,當我想添加圖片時,主要顏色被設置爲透明。然後線條是透明的,但點(應該連接)具有正確的顏色。任何想法可能是錯誤的?