Android Canvas - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Canvas class.

This code example shows how to use the following methods: drawPath, restore, save, scale, translate
		super.onDraw(canvas);
 
		if (path != null) {
			int w = getWidth()/2;
			int h = getHeight()/2;
			canvas.save();
			canvas.scale(w,h);
			if (!leftArrow) {
				canvas.translate(1, 0);
			} 
			Paint p = new Paint();
			p.setAntiAlias(false);
			p.setARGB(175, 216, 216, 216);
			p.setStyle(Paint.Style.FILL);
			canvas.drawPath(path, p);
			p.setARGB(75, 0, 0, 0);
			p.setStrokeWidth(0.1f);
			p.setStrokeJoin(Join.ROUND);
			p.setStrokeCap(Cap.ROUND);
			p.setAntiAlias(true);

9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: drawRGB, drawRect, restore, rotate, save
            mPaint.setAntiAlias(true);
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            canvas.save();
            canvas.translate(dipToPx(getContext(), 400), dipToPx(getContext(), 200));
            canvas.rotate(45.0f);
            canvas.drawRGB(255, 255, 255);
            mPaint.setColor(0xffff0000);
            canvas.drawRect(-80.0f, -80.0f, 80.0f, 80.0f, mPaint);
            canvas.drawRect(0.0f, 0.0f, 220.0f, 220.0f, mPaint);            
            canvas.restore();
        } 
    } 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: drawBitmap, translate
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
             
            Log.d("OpenGLRenderer", "================= Draw");
 
            canvas.translate(120.0f, 50.0f);
            canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mBitmapPaint);
 
            canvas.translate(0.0f, mBitmap1.getHeight());
            canvas.translate(0.0f, 25.0f);
            canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, null);
             
            canvas.translate(0.0f, mBitmap2.getHeight());
            canvas.translate(0.0f, 25.0f);
            canvas.drawBitmap(mBitmap3, 0.0f, 0.0f, null);
        } 
    } 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: drawBitmap, drawRect
        if (mNeedRebuild) {
 
            if (mMapPin == null) {
                mMapPin = Bitmap.createBitmap(mBase.getWidth(), mBase.getHeight(), Bitmap.Config.ARGB_8888);
            } 
            Canvas c = new Canvas(mMapPin);
            c.drawRect(0, 0, mMapPin.getWidth(), mMapPin.getHeight(), sClearerPaint);
 
            // 1 - Draw the base 
            c.drawBitmap(mBase, 0, 0, null);
            // 2 - Draw the pin on top of it 
            mPaint.setColorFilter(new LightingColorFilter(Color.BLACK, mCurrentPinColor));
            c.drawBitmap(mPin, 0, 0, mPaint);
            // 3 - Draw the dot on top of everything 
            mPaint.setColorFilter(new LightingColorFilter(Color.BLACK, mCurrentDotColor));
            c.drawBitmap(mDot, 0, 0, mPaint);
 
            mNeedRebuild = false;
        } 
 
        canvas.drawBitmap(mMapPin, null, getBounds(), mMapPinPaint);
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: drawRect, restore, save, translate
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            //canvas.drawRGB(255, 255, 255); 
 
            canvas.translate(100.0f, 100.0f);
             
            // SRC modes 
            canvas.save();
 
            drawRects(canvas, Mode.SRC_OVER);
            canvas.translate(0.0f, 100.0f);
 
            drawRects(canvas, Mode.SRC_IN);
            canvas.translate(0.0f, 100.0f);            
 
            drawRects(canvas, Mode.SRC_OUT);
            canvas.translate(0.0f, 100.0f);
 
            drawRects(canvas, Mode.SRC_ATOP);

9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android Canvas Questions & Answers:

See Code Examples for Android Canvas Methods: