Добавьте поле между каждым растровым изображением на холсте - PullRequest
0 голосов
/ 02 июня 2019

Я пытаюсь нарисовать 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

...