Best code examples for Android GradientDrawable class (android.graphics.drawable.GradientDrawable)

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

Android GradientDrawable examples from Open Source projects
This code example shows how to use the following methods: setCornerRadius, setGradientRadius, setShape
37:	mDrawPressed = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, 
-
39:	mDrawPressed.setShape(GradientDrawable.RECTANGLE); 
40:	mDrawPressed.setGradientRadius((float)(Math.sqrt(2) * 60)); 
41:	mDrawPressed.setCornerRadius(8); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setBounds, setLevel, draw, setDither
558:	GradientDrawable gradDraw = new GradientDrawable(Orientation.TOP_BOTTOM, colors); 
559:	gradDraw.setDither(true); 
560:	gradDraw.setLevel(10000); 
561:	gradDraw.setBounds(0, 0, SLIDER_THICKNESS, PALETTE_DIM); 
562:	gradDraw.draw(mVerSliderCv); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setStroke
314:	gd.setStroke(dipToInt(strokeDips), strokeColor); 
-
322:	GradientDrawable gd = new GradientDrawable(orientation, colors); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setColor, setCornerRadius, setStroke
400:	final GradientDrawable popupbackground = new GradientDrawable(); 
401:	popupbackground.setCornerRadius(cornerradiusDPI * getResources().getDisplayMetrics().density); 
402:	popupbackground.setStroke((int) (borderwidthDPI * getResources().getDisplayMetrics().density), bordercolor); 
403:	popupbackground.setColor(backgroundcolor); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setCornerRadius, setGradientRadius, setShape
36:	mDrawPressed = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, 
-
38:	mDrawPressed.setShape(GradientDrawable.RECTANGLE); 
39:	mDrawPressed.setGradientRadius((float)(Math.sqrt(2) * 60)); 
40:	mDrawPressed.setCornerRadius(8); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods:
88:	mGradientDrawable = new GradientDrawable(currentOrientation, mGradientColors); 
-
92:	ApiCompatibilityUtils.setBackgroundForView(mGradientView, mGradientDrawable); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setColor, setCornerRadius, setStroke
55:	GradientDrawable gd = new GradientDrawable( ) ; 
56:	gd.setStroke(1,stroke); 
57:	gd.setCornerRadius (RADIUS) ; 
58:	gd.setColor ( background) ; 
59:	setBackgroundDrawable(gd) ; 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setCornerRadius, setGradientRadius, setShape
34:	mDrawSelected = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, 
-
36:	mDrawSelected.setShape(GradientDrawable.RECTANGLE); 
37:	mDrawSelected.setGradientRadius((float)(Math.sqrt(2) * 60)); 
38:	mDrawSelected.setCornerRadius(8); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setColor, setCornerRadius, setStroke
103:	GradientDrawable gd = new GradientDrawable(); 
104:	gd.setColor(cardColor); 
105:	gd.setCornerRadius(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, context.getResources().getDisplayMetrics())); 
106:	gd.setStroke((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, context.getResources().getDisplayMetrics()), backgroundColor); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: drawLine, getClipBounds, draw
28:	if (!canvas.getClipBounds().isEmpty()) { 
-
44:	style.face.draw(canvas); 
-
53:	canvas.drawLine(x, 0, x, height, paint); 
-
57:	style.face.draw(canvas); 
-
61:	canvas.drawLine(x, 0, x, height, paint); 
-
65:	canvas.drawLine(x, 0, x, height, paint); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw
316:	if (mShowTopShadow) mShadow.draw(canvas); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setColor, setCornerRadius, setStroke
145:	GradientDrawable borderLayer=new GradientDrawable(); 
-
147:	borderLayer.setStroke(borderBottomSize, Color.parseColor(this.baseVeilColor)); 
148:	borderLayer.setCornerRadius(this.cornerRadius); 
149:	borderLayer.setColor(Color.TRANSPARENT); 
150:	layers.add(borderLayer); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setBounds, draw, setCornerRadii, setGradientType
59:	drawable.setCornerRadii(new float[] { r0, r0, r1, r1, 
-
65:	mDrawable.setBounds(mRect); 
-
71:	mDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); 
-
73:	mDrawable.draw(canvas); 
-
78:	mDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); 
-
80:	mDrawable.draw(canvas); 
-
87:	mDrawable.setGradientType(GradientDrawable.SWEEP_GRADIENT); 
-
89:	mDrawable.draw(canvas); 
-
94:	mDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); 
-
96:	mDrawable.draw(canvas); 
-
103:	mDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); 
-
105:	mDrawable.draw(canvas); 
-
110:	mDrawable.setGradientType(GradientDrawable.SWEEP_GRADIENT); 
-
112:	mDrawable.draw(canvas); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBounds, draw, setDither
162:	GradientDrawable gradient = new GradientDrawable(Orientation.TL_BR, 
-
164:	gradient.setDither(true); 
165:	gradient.setBounds(padding, 0, getWidth() - padding, getGradHeight()); 
166:	gradient.draw(canvas); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setCornerRadius, setGradientRadius, setShape
36:	mDrawPressed = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, 
-
38:	mDrawPressed.setShape(GradientDrawable.RECTANGLE); 
39:	mDrawPressed.setGradientRadius((float)(Math.sqrt(2) * 60)); 
40:	mDrawPressed.setCornerRadius(8); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: invalidateSelf, setColor
100:	mPreviewDrawable.setColor(color); 
101:	mPreviewDrawable.invalidateSelf(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods:
90:	return new GradientDrawable( 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setBounds, draw
35:	topDrawable.setBounds(bounds); 
36:	topDrawable.draw(canvas); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setGradientCenter, setGradientRadius, setGradientType
56:	GradientDrawable gradient = new GradientDrawable(Orientation.TL_BR, colors); 
57:	gradient.setGradientType(GradientDrawable.RADIAL_GRADIENT); 
58:	gradient.setGradientRadius(radius); 
59:	gradient.setGradientCenter(0.5f, 0.5f); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setCornerRadius
23:	GradientDrawable gd = new GradientDrawable(); 
24:	gd.setCornerRadius(RADIUS); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setCornerRadius
197:	GradientDrawable gd = new GradientDrawable(Orientation.RIGHT_LEFT, COLORS); 
198:	gd.setCornerRadius(BAR_CORNER); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods:
167:	return new GradientDrawable( 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setCornerRadius, setGradientRadius, setShape
32:	mDrawSelected = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, 
-
34:	mDrawSelected.setShape(GradientDrawable.RECTANGLE); 
35:	mDrawSelected.setGradientRadius((float)(Math.sqrt(2) * 60)); 
36:	mDrawSelected.setCornerRadius(8); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setCornerRadius
197:	GradientDrawable gd = new GradientDrawable(Orientation.RIGHT_LEFT, COLORS); 
198:	gd.setCornerRadius(BAR_CORNER); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setColor, setShape, setStroke
80:	GradientDrawable drawable = new GradientDrawable(); 
81:	drawable.setShape(GradientDrawable.RECTANGLE); 
82:	drawable.setStroke(1, Color.WHITE); 
83:	drawable.setColor(Color.BLACK); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setCornerRadius, setGradientRadius, setShape
37:	mDrawPressed = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, 
-
39:	mDrawPressed.setShape(GradientDrawable.RECTANGLE); 
40:	mDrawPressed.setGradientRadius((float)(Math.sqrt(2) * 60)); 
41:	mDrawPressed.setCornerRadius(8); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: invalidateSelf, setColor
106:	mPreviewDrawable.setColor(color); 
107:	mPreviewDrawable.invalidateSelf(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBounds, setLevel, draw, setDither
558:	GradientDrawable gradDraw = new GradientDrawable(Orientation.TOP_BOTTOM, colors); 
559:	gradDraw.setDither(true); 
560:	gradDraw.setLevel(10000); 
561:	gradDraw.setBounds(0, 0, SLIDER_THICKNESS, PALETTE_DIM); 
562:	gradDraw.draw(mVerSliderCv); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBounds, draw, setColors
250:	mBarGradient.setBounds(0, 0, (int)(width*size), mHeight); 
251:	mBarGradient.setColors(mGradientColors); 
252:	mBarGradient.draw(canvas); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setAlpha, setCornerRadius
17:	GradientDrawable d = new GradientDrawable(Orientation.TOP_BOTTOM, new int[]{Color.rgb(63, 61, 65), Color.rgb(63, 61, 65)}); 
18:	d.setCornerRadius(10); 
19:	d.setAlpha(200); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setColor, setShape, setStroke
267:	colorChoiceDrawable = new GradientDrawable(); 
268:	colorChoiceDrawable.setShape(GradientDrawable.OVAL); 
-
277:	colorChoiceDrawable.setColor(color); 
278:	colorChoiceDrawable.setStroke((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setColor, setCornerRadii, setStroke
211:	borderLayer=new GradientDrawable(); 
212:	borderLayer.setStroke(borderBottomSize, Color.parseColor(endPressedColor)); 
213:	borderLayer.setCornerRadii(cornerRadius); 
214:	borderLayer.setColor(Color.TRANSPARENT); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBounds, draw, setColors
95:	GradientDrawable gd = new GradientDrawable(); 
-
98:	gd.setBounds((int) x, (int) y, (int) width, (int) height); 
-
104:	gd.setColors(colors); 
-
107:	gd.draw(canvas); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBounds, draw
43:	GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xffdcdcdc, 0xff111111 }); 
44:	grad.setBounds(0, 0, this.getWidth(), this.getHeight()); 
45:	grad.draw(canvas); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setCornerRadii
160:	final GradientDrawable d = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, 
-
162:	d.setCornerRadii(CORNERS); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setCornerRadius, setStroke
20:	GradientDrawable shape = new GradientDrawable(orientation, colors); 
21:	shape.setStroke(borderWidth, borderColor); 
22:	shape.setCornerRadius(cornerRadius); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBounds, draw
50:	GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xffdcdcdc, 0xff111111 }); 
51:	grad.setBounds(0, 0, this.getWidth(), this.getHeight()); 
52:	grad.draw(canvas); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBounds, draw
50:	GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xffdcdcdc, 0xff111111 }); 
51:	grad.setBounds(0, 0, this.getWidth(), this.getHeight()); 
52:	grad.draw(canvas); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setCornerRadius, setStroke
14:	GradientDrawable drawable = new GradientDrawable(Orientation.TOP_BOTTOM, new int[]{Color.rgb(128, 128, 128), Color.rgb(128, 128, 128)}); 
15:	drawable.setCornerRadius(10); 
16:	drawable.setStroke(2, Color.BLACK); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBounds, draw
52:	GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xffdcdcdc, 0xff111111 }); 
53:	grad.setBounds(0, 0, (this.getWidth()), (this.getHeight())); 
54:	grad.draw(canvas); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBounds, draw
57:	GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xffa5a5a5, 0xff000000 }); 
58:	grad.setBounds(0, 0, this.getWidth(), this.getHeight()); 
59:	grad.draw(canvas); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setColor, setCornerRadius
25:	GradientDrawable gd = new GradientDrawable(); 
26:	gd.setCornerRadius(RADIUS); 
27:	gd.setColor(0xff999999); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBounds, draw
56:	GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xffa5a5a5, 0xff000000 }); 
57:	grad.setBounds(0, 0, this.getWidth(), this.getHeight()); 
58:	grad.draw(canvas); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setCornerRadius, setShape
56:	GradientDrawable grad = new GradientDrawable(Orientation.BR_TL, new int[] { color, color - 0x88000000 }); 
57:	grad.setShape(GradientDrawable.RECTANGLE); 
58:	grad.setCornerRadius(10); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setCornerRadius, setShape
29:	bgGradDrawable.setShape(GradientDrawable.RECTANGLE); 
-
31:	ClipDrawable bgclip = new ClipDrawable( 
32:	bgGradDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setCornerRadius, setDither
39:	GradientDrawable d = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, colors); 
40:	d.setDither(true); 
-
47:	d.setCornerRadius(5); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setCornerRadius
43:	public LabelView(Context context, AttributeSet attrs) { 
-
62:	drawable.setCornerRadius(4.0f); 
Full Snippet Info
5
CodeRank
Related Android GradientDrawable Questions & Answers:
See Code Examples for Android GradientDrawable Methods: