在画布上绘制的每个位图之间添加边距

时间:2019-06-02 19:36:43

标签: java android drawing margin android-bitmap

我试图在画布上多次绘制Bitmap,我的代码给了我这个:

enter image description here

代码:

public DrawView(Context context) {
        super(context);
        setFocusable(true);
        setFocusableInTouchMode(true);
        setOnTouchListener(this);
        this.paint.setColor(Color.TRANSPARENT);
        this.paint.setAntiAlias(true);
        this.mContext = context;
    }

    public void onDraw(Canvas canvas) {
        this.ch = getHeight();
        this.cw = getWidth();
        for (Point point : this.points) {
            canvas.drawBitmap(point.bt, point.x, point.y, null);
        }
    }


    public void drawSingleEmoji(MotionEvent motionEvent, Bitmap singleBitmap) {
        this.bt1 = singleBitmap;
        this.bt2 = Bitmap.createScaledBitmap(this.bt1, w, h, true);
        Point point = new Point();
        point.x = motionEvent.getX() - ((float) (this.bt2.getWidth() / 2));
        point.y = motionEvent.getY() - ((float) (this.bt2.getHeight() / 2));
        point.bt = this.bt2;
        this.points.add(point);
        invalidate();
    }

    public boolean onTouch(View view, MotionEvent motionEvent) {
       drawSingleEmoji(motionEvent,bitSingle);
        return true;
    }

    public void setEmoji(Bitmap textAsBitmap) {
        bitSingle = textAsBitmap;
    }
}

我如何调整淹没在画布上的每个表情符号之间的间距:

enter image description here

0 个答案:

没有答案