Best code examples for Android Paint class (android.graphics.Paint)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Paint class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android Paint examples from Open Source projects
This code example shows how to use the following methods: setAntiAlias, setColor, setXfermode
28:	Paint paint = new Paint(); 
29:	paint.setAntiAlias(true); 
30:	paint.setColor(WHITE); 
-
35:	paint.setXfermode(new PorterDuffXfermode(DST_IN)); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setStyle, setXfermode
82:	mPaint = new Paint(); 
83:	mPaint.setAntiAlias(true); 
84:	mPaint.setColor(Color.BLACK); 
85:	mPaint.setStyle(Paint.Style.FILL); 
-
89:	mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)); 
-
93:	mPaint.setXfermode(null); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
15:	private final Paint paint = new Paint(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setColor, setStyle
53:	Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 
54:	paint.setColor(0x186666ff); 
55:	paint.setStyle(Style.FILL_AND_STROKE); 
-
58:	paint.setColor(0xff6666ff); 
59:	paint.setStyle(Style.STROKE); 
-
62:	paint.setColor(Color.RED); 
63:	paint.setStyle(Style.FILL_AND_STROKE); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: measureText, setTextSize, setTypeface
198:	Paint paint = new Paint(); 
199:	paint.setTypeface(view.getTypeface()); 
200:	paint.setTextSize(view.getTextSize()); 
-
203:	return Math.round(paint.measureText(text, 0, text.length)); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setDither, setFilterBitmap
119:	mPaint = new Paint(); 
120:	mPaint.setFilterBitmap(true); 
121:	mPaint.setColor(Color.rgb(255, 255, 255)); // TODO: make configurable 
122:	mPaint.setAntiAlias(true); 
123:	mPaint.setDither(true); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setTextSize
45:	mHugePaint = new Paint(); 
46:	mHugePaint.setAntiAlias(true); 
47:	mHugePaint.setColor(0xff000000); 
48:	mHugePaint.setTextSize(300f); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setColor, setStrokeWidth, setStyle
24:	strokepaint = new Paint(fillpaint); 
25:	strokepaint.setStyle(Paint.Style.STROKE); 
26:	strokepaint.setStrokeWidth(strokeWidth); 
27:	strokepaint.setColor(stroke); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias
47:	mPaint = new Paint(); 
48:	mPaint.setAntiAlias(true); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setFakeBoldText, setTextSize
76:	mEventPaint = new TextPaint(); 
77:	mEventPaint.setFakeBoldText(true); 
78:	mEventPaint.setAntiAlias(true); 
79:	mEventPaint.setTextSize(14); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setARGB, setAntiAlias, setStrokeCap, setStrokeJoin, setStrokeWidth
72:	Paint p = new Paint(); 
73:	p.setAntiAlias(false); 
74:	p.setARGB(175, 216, 216, 216); 
75:	p.setStyle(Paint.Style.FILL); 
-
77:	p.setARGB(75, 0, 0, 0); 
78:	p.setStrokeWidth(0.1f); 
79:	p.setStrokeJoin(Join.ROUND); 
80:	p.setStrokeCap(Cap.ROUND); 
81:	p.setAntiAlias(true); 
82:	p.setStyle(Paint.Style.STROKE); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getFontMetricsInt, measureText, setColor, setTextAlign, setTextSize
42:	mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 
43:	mPaint.setColor(DEFAULT_COLOR); 
44:	mPaint.setTextAlign(Align.CENTER); 
-
47:	mPaint.setTextSize(textSize); 
48:	mIntrinsicWidth = (int) (mPaint.measureText(mText, 0, mText.length()) + .5); 
49:	mIntrinsicHeight = mPaint.getFontMetricsInt(null); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setFakeBoldText, setTextSize
127:	paintSelected = new Paint(); 
128:	paintSelected.setColor(selectedColor); 
129:	paintSelected.setTextSize(selectedSize); 
130:	paintSelected.setFakeBoldText(selectedBold); 
131:	paintSelected.setAntiAlias(true); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAlpha, setColor
112:	mBluePaint.setAlpha(127); 
-
117:	mBluePaint.setAlpha(10); 
118:	mBluePaint.setColor(0x7f0000ff); 
-
121:	mBluePaint.setColor(0xff0000ff); 
122:	mBluePaint.setAlpha(255); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setXfermode
237:	Paint paint = new Paint(); 
238:	paint.setAntiAlias(true); 
239:	paint.setColor(WHITE); 
-
245:	paint.setXfermode(new PorterDuffXfermode(DST_IN)); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getColor, getStyle, setColor, setStyle
77:	Paint.Style style = p.getStyle(); 
-
81:	oldcolor = p.getColor(); 
82:	p.setColor(mColor); 
-
85:	p.setStyle(Paint.Style.FILL); 
-
90:	p.setColor(oldcolor); 
-
93:	p.setStyle(style); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setColor, setStyle, setTextAlign, setTextSize
60:	Paint paint = new Paint(); 
61:	paint.setColor(BG_COLOR); 
62:	paint.setStyle(Paint.Style.FILL); 
-
65:	paint.setColor(FILTER_COLOR); 
-
74:	paint.setColor(TEXT_COLOR); 
75:	paint.setTextAlign(Paint.Align.CENTER); 
76:	paint.setTextSize(16); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor
58:	mPaint = new Paint(); 
59:	mPaint.setAntiAlias(true); 
60:	mPaint.setColor(0xffffffff); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setColor, setColorFilter, setMaskFilter
130:	Paint paint = new Paint(); 
131:	paint.setColor(glowColor); 
-
135:	paint.setColorFilter(emphasize); 
-
137:	paint.setColorFilter(null); 
138:	paint.setMaskFilter(new BlurMaskFilter(glowRadius, Blur.OUTER)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setColor
16:	final Paint p = new Paint(); 
17:	p.setColor(Color.GRAY); 
18:	Drawable d = new Drawable() { 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setStrokeWidth, setStyle
37:	final Paint mEdgeGradientPaint = new Paint(); 
-
45:	mEdgeGradientPaint.setStyle(Paint.Style.STROKE); 
-
48:	mEdgeGradientPaint.setStrokeWidth(mLineWidth); 
49:	mEdgeGradientPaint.setAntiAlias(true); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setColor, setStyle
151:	final Paint p = new Paint(); 
152:	p.setColor(color); 
153:	p.setStyle(Paint.Style.FILL); 
154:	return new Entry(order, percentage, p); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setXfermode
57:	Paint paint = new Paint(); 
58:	paint.setAntiAlias(true); 
59:	paint.setColor(0xff424242); 
-
67:	paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getStrokeWidth, setColor, setStyle
72:	private final Paint mPaintInactive = new Paint(Paint.ANTI_ALIAS_FLAG); 
-
152:	mPaintInactive.setStyle(Style.FILL); 
-
155:	mPaintInactive.setStyle(Style.STROKE); 
156:	float strokeWidth = mPaintInactive.getStrokeWidth(); 
-
163:	mPaintInactive.setColor(inactiveColor); 
-
169:	float strokeWidth = mPaintInactive.getStrokeWidth(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAlpha, setColor, setColorFilter, setTextSize
22:	Paint paint = new Paint(); 
-
24:	paint.setColorFilter(filter); 
25:	paint.setAlpha(opacity); 
-
27:	paint.setTextSize(12); 
28:	paint.setColor(Color.GREEN); 
-
31:	paint.setTextSize(16); 
32:	paint.setColor(Color.RED); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setColor, setStrokeWidth, setStyle
123:	Paint pt = new Paint(); 
124:	pt.setColor(0x80FFFF00); 
125:	pt.setStrokeWidth(12.0f); 
126:	pt.setStyle(Paint.Style.STROKE); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setStrokeWidth, setStyle, setTextSize
60:	mTextPaintOutline = new TextPaint(); 
61:	mTextPaintOutline.setAntiAlias(true); 
62:	mTextPaintOutline.setTextSize(getTextSize()); 
63:	mTextPaintOutline.setColor(mBorderColor); 
64:	mTextPaintOutline.setStyle(Paint.Style.STROKE); 
65:	mTextPaintOutline.setTypeface(getTypeface()); 
66:	mTextPaintOutline.setStrokeWidth(mBorderSize); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setStyle, setXfermode
103:	mPaint = new Paint(); 
104:	mPaint.setAntiAlias(true); 
105:	mPaint.setColor(Color.BLACK); 
106:	mPaint.setStyle(Paint.Style.FILL); 
-
110:	mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)); 
-
114:	mPaint.setXfermode(null); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
11:	private Paint paint = new Paint(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setStrokeWidth, setStyle
53:	private Paint mPaintOutline = new Paint(); 
-
88:	mPaintOutline.setColor(Color.BLACK); 
89:	mPaintOutline.setStyle(Style.STROKE); 
90:	mPaintOutline.setStrokeWidth(3f * getResources().getDisplayMetrics().density); 
91:	mPaintOutline.setAntiAlias(true); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setXfermode
175:	Paint paint = new Paint(); 
176:	paint.setAntiAlias(true); 
177:	paint.setColor(WHITE); 
-
183:	paint.setXfermode(new PorterDuffXfermode(DST_IN)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setStrokeWidth, setStyle
55:	mStrokePaint = new Paint(); 
56:	mStrokePaint.setAntiAlias(true); 
57:	mStrokePaint.setColor(0xff0000ff); 
58:	mStrokePaint.setStrokeWidth(6.0f); 
59:	mStrokePaint.setStyle(Paint.Style.STROKE); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setShadowLayer, setStrokeWidth
17:	private Paint mPaint = new Paint(); 
-
31:	mPaint.setStrokeWidth(5); 
32:	mPaint.setColor(Color.parseColor("#33B5E5")); 
33:	mPaint.setAntiAlias(true); 
34:	mPaint.setShadowLayer(10.0f, 0.0f, 2.0f, 0xFF000000); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
13:	private final Paint paint = new Paint(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setColor, setShadowLayer, setTextSize, setTypeface
277:	valuePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG 
-
281:	valuePaint.setTextSize(textSize); 
282:	valuePaint.setShadowLayer(0.5f, 0, 0.5f, 0xFFFFFFFF); 
283:	valuePaint.setTypeface(typeface); 
284:	valuePaint.setColor((textColor == NOVAL) ? ITEMS_TEXT_COLOR : textColor); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setColor, setTextSize
32:	mPaint = new Paint(); 
33:	mPaint.setColor(Color.BLUE); 
34:	mPaint.setTextSize(20); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setStyle
28:	mBorderPaint = new Paint(); 
29:	mBorderPaint.setAntiAlias(true); 
30:	mBorderPaint.setColor(0xFF000000); 
31:	mBorderPaint.setStyle(Paint.Style.STROKE); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setColor, setStrokeWidth, setStyle
25:	paint = new Paint(); 
26:	paint.setColor(0xffffffff); 
27:	paint.setStyle(Style.STROKE); 
28:	paint.setStrokeWidth(strokeWidth); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
37:	private static final Paint DEBUG_PAINT = new Paint(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setColorFilter, setShader
133:	mLargePaint.setShader(mHorGradient); 
-
136:	mLargePaint.setShader(mScaled2Shader); 
-
139:	mLargePaint.setShader(mCompose2Shader); 
140:	mLargePaint.setColorFilter(mColorFilter); 
-
142:	mLargePaint.setColorFilter(null); 
-
145:	mLargePaint.setShader(mVertGradient); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
72:	mBitmapPaint = new Paint(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setStyle, setTextAlign, setTextSize
76:	final Paint paint = new Paint(); 
-
81:	paint.setColor(Color.BLACK); 
82:	paint.setStyle(Style.FILL); 
83:	paint.setAntiAlias(true); 
84:	paint.setTextAlign(Align.CENTER); 
85:	paint.setTextSize(24.0f); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAlpha, setColor
112:	mBluePaint.setAlpha(127); 
-
117:	mBluePaint.setAlpha(10); 
118:	mBluePaint.setColor(0x7f0000ff); 
-
121:	mBluePaint.setColor(0xff0000ff); 
122:	mBluePaint.setAlpha(255); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
65:	mPaint = new Paint(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAntiAlias, setColor, setStrokeWidth, setTextSize
59:	Paint paint = new Paint(); 
60:	paint.setAntiAlias(true); 
-
62:	effect.setEffect(paint); 
63:	paint.setColor(Color.DKGRAY); 
-
65:	paint.setStrokeWidth(5); 
-
68:	paint.setTextSize(26); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
11:	private Paint paint = new Paint(); 
Full Snippet Info
8
CodeRank
Related Android Paint Questions & Answers:
See Code Examples for Android Paint Methods: