خرید بک لینک

Vote count: 0

I am trying to add stroke to my shape. I draw simple square. Then I draw outline. Here is what happened.

Rslt

Source code:

MyImageView extends ImageView 
    ...
        public void initSquare(int w, int h) {
            initPath();
            initPaint();
            initPaintStroke();
            float lrg = w;
            clipPath.moveTo(0, 0);
            clipPath.lineTo(lrg, 0);
            clipPath.lineTo(lrg, lrg);
            clipPath.lineTo(0, lrg);
        }

    @Override
    protected void onDraw(Canvas canvas) {
        if (isPreview && clipPath!=null) {
            canvas.drawPath(clipPath, mpaint);
            canvas.drawPath(clipPath, heart_outline_paint);
        }
        super.onDraw(canvas);
    }

    public void initPaint(){
        if (mpaint!=null) mpaint.reset();
        mpaint = new Paint();
        mpaint.setAntiAlias(true);
        mpaint.setColor(Color.WHITE);
        mpaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
    }

    public void initPaintStroke() {
        if (heart_outline_paint!=null) heart_outline_paint.reset();
        heart_outline_paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        heart_outline_paint.setStrokeJoin(Paint.Join.MITER);
        heart_outline_paint.setColor(Color.WHITE); // Change the boundary color
        heart_outline_paint.setStrokeWidth(15);
        heart_outline_paint.setStyle(Paint.Style.STROKE);
    }

    public void initPath() {
        if (clipPath!=null) clipPath.reset();
        clipPath = new Path();
    }
...

My question is what is going wrong? Is it not a problem I am overriding ImageView's "onDraw"?

asked 32 secs ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 18 اسفند 1394 ساعت: 10:00

صفحه بندی