@Override public IBuilder roundRect(int radius) { this.radius = radius; float[] radii = {radius, radius, radius, radius, radius, radius, radius, radius}; this.shape = new RoundRectShape(radii, null, null); return this; }
@Override public IBuilder round() { this.shape = new OvalShape(); return this; }
@Override public IBuilder rect() { this.shape = new RectShape(); return this; }
public ColorChip(int color, Path shape) { if (shape.equals(STAR)) { mDrawable = new ShapeDrawable(new PathShape(shape, 280f, 280f)); } else { mDrawable = new ShapeDrawable(new PathShape(shape, 320f, 320f)); } mDrawable.getPaint().setStyle(Paint.Style.FILL_AND_STROKE); mDrawable.getPaint().setStrokeWidth(20); mDrawable.getPaint().setColor(color); }
@Override protected void onResize(float width, float height) { super.onResize(width, height); updateRadialGradient((int) width); }
public ShapeAssert hasAlpha() { isNotNull(); assertThat(actual.hasAlpha()) // .overridingErrorMessage("Expected to have alpha but did not.") // .isTrue(); return this; }
new Predicate<Shape>() { public boolean test(Shape s) { return s.getColor() == Color.RED; } }
OvalShadow(int shadowRadius) { super(); mShadowPaint = new Paint(); mShadowRadius = shadowRadius; updateRadialGradient((int) super.rect().width()); }
static ShapeDrawable getCircle(ComponentContext c) { final ShapeDrawable oval = new ShapeDrawable(new OvalShape()); oval.getPaint().setColor(Color.LTGRAY); return oval; }
static ShapeDrawable getMessageBackground(ComponentContext c, int color) { final RoundRectShape roundedRectShape = new RoundRectShape( new float[] {40, 40, 40, 40, 40, 40, 40, 40}, null, new float[] {40, 40, 40, 40, 40, 40, 40, 40}); final ShapeDrawable oval = new ShapeDrawable(roundedRectShape); oval.getPaint().setColor(color); return oval; }
private Builder() { text = ""; color = Color.GRAY; textColor = Color.WHITE; borderThickness = 0; width = -1; height = -1; shape = new RectShape(); font = Typeface.create("sans-serif-light", Typeface.NORMAL); fontSize = -1; isBold = false; toUpperCase = false; }
private static Drawable generateCircleDrawable(final int color) { ShapeDrawable drawable = new ShapeDrawable(new OvalShape()); drawable.getPaint().setColor(color); return drawable; }
private static Drawable buildRoundedRect(int radius, int color) { final float[] radii = new float[8]; Arrays.fill(radii, radius); final RoundRectShape roundedRectShape = new RoundRectShape(radii, null, radii); final ShapeDrawable drawable = new ShapeDrawable(roundedRectShape); drawable.getPaint().setColor(color); return drawable; } }
int h = v.getHeight(); ShapeDrawable mDrawable = new ShapeDrawable(new RectShape()); mDrawable.getPaint().setShader(new LinearGradient(0, 0, 0, h, Color.parseColor("#330000FF"), Color.parseColor("#110000FF"), Shader.TileMode.REPEAT)); v.setBackgroundDrawable(mDrawable);
private Drawable createCircleDrawable(int color) { CircleDrawable shapeDrawable = new CircleDrawable(new OvalShape()); shapeDrawable.getPaint().setColor(color); return shapeDrawable; }
private Drawable createRectDrawable(int color) { RoundRectShape shape = new RoundRectShape( new float[]{ mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius }, null, null); ShapeDrawable shapeDrawable = new ShapeDrawable(shape); shapeDrawable.getPaint().setColor(color); return shapeDrawable; }
ShapeDrawable.ShaderFactory sf = new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { LinearGradient lg = new LinearGradient(0, 0, width, height, new int[]{Color.GREEN, Color.GREEN, Color.WHITE, Color.WHITE}, new float[]{0,0.5f,.55f,1}, Shader.TileMode.REPEAT); return lg; } }; PaintDrawable p=new PaintDrawable(); p.setShape(new RectShape()); p.setShaderFactory(sf);
private LayerDrawable makeClusterBackground() { mColoredCircleBackground = new ShapeDrawable(new OvalShape()); ShapeDrawable outline = new ShapeDrawable(new OvalShape()); outline.getPaint().setColor(0x80ffffff); // Transparent white. LayerDrawable background = new LayerDrawable(new Drawable[]{outline, mColoredCircleBackground}); int strokeWidth = (int) (mDensity * 3); background.setLayerInset(1, strokeWidth, strokeWidth, strokeWidth, strokeWidth); return background; }
ShapeDrawable footerBackground = new ShapeDrawable(); // The corners are ordered top-left, top-right, bottom-right, // bottom-left. For each corner, the array contains 2 values, [X_radius, // Y_radius] float[] radii = new float[8]; radii[0] = activity.getResources().getDimension(R.dimen.footer_corners); radii[1] = activity.getResources().getDimension(R.dimen.footer_corners); radii[2] = activity.getResources().getDimension(R.dimen.footer_corners); radii[3] = activity.getResources().getDimension(R.dimen.footer_corners); footerBackground.setShape(new RoundRectShape(radii, null, null)); int color = ((Application) activity.getApplication()).getColor(); footerBackground.getPaint().setColor(color); views.setBackgroundDrawable(footerBackground);
Button theButton = (Button)findViewById(R.id.thebutton); ShapeDrawable.ShaderFactory sf = new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { LinearGradient lg = new LinearGradient(0, 0, 0, theButton.getHeight(), new int[] { Color.LIGHT_GREEN, Color.WHITE, Color.MID_GREEN, Color.DARK_GREEN }, //substitute the correct colors for these new float[] { 0, 0.45f, 0.55f, 1 }, Shader.TileMode.REPEAT); return lg; } }; PaintDrawable p = new PaintDrawable(); p.setShape(new RectShape()); p.setShaderFactory(sf); theButton.setBackgroundDrawable((Drawable)p);