@Override public IBuilder rect() { this.shape = new RectShape(); return this; }
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; }
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);
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);
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);
paintDrawable.setShape(new RectShape());
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 void FillCustomGradient(View v) { final View view = v; Drawable[] layers = new Drawable[1]; ShapeDrawable.ShaderFactory sf = new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { LinearGradient lg = new LinearGradient( 0, 0, 0, view.getHeight(), new int[] { getResources().getColor(R.color.color1), // please input your color from resource for color-4 getResources().getColor(R.color.color2), getResources().getColor(R.color.color3), getResources().getColor(R.color.color4)}, new float[] { 0, 0.49f, 0.50f, 1 }, Shader.TileMode.CLAMP); return lg; } }; PaintDrawable p = new PaintDrawable(); p.setShape(new RectShape()); p.setShaderFactory(sf); p.setCornerRadii(new float[] { 5, 5, 5, 5, 0, 0, 0, 0 }); layers[0] = (Drawable) p; LayerDrawable composite = new LayerDrawable(layers); view.setBackgroundDrawable(composite); }
ShapeDrawable sd = new ShapeDrawable(new RectShape()); sd.setIntrinsicHeight(1); Paint fgPaintSel = sd.getPaint(); fgPaintSel.setARGB(255, 0, 0, 0); fgPaintSel.setStyle(Paint.Style.STROKE); fgPaintSel.setPathEffect(new DashPathEffect(new float[]{5, 10}, 0)); LinearLayout linearLayout = (LinearLayout) findViewById(R.id.main); linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE | LinearLayout.SHOW_DIVIDER_END); linearLayout.setDividerDrawable(sd);
private Builder() { text = ""; color = Color.GRAY; textColor = Color.WHITE; borderThickness = 0; width = -1; height = -1; shape = new RectShape(); fontSize = -1; isBold = false; toUpperCase = false; }
@Override public IBuilder rect() { this.shape = new RectShape(); return this; }
@Override public IBuilder rect() { this.shape = new RectShape(); return this; }
@Override public IBuilder rect() { this.shape = new RectShape(); return this; }
int x = 10; int y = 10; int width = 300; int height = 50; mDrawable = new ShapeDrawable(new RectShape()); // rectangle for border mDrawable.getPaint().setColor(0xff74AC23); // set color mDrawable.setBounds(x, y, x + width, y + height); setContentView(mDrawable);
LinearGradient test = new LinearGradient(0.f, 0.f, 300.f, 0.0f, new int[] { 0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF, 0xFFFF0000, 0xFFFF00FF, 0xFFFFFF00, 0xFFFFFFFF}, null, TileMode.CLAMP); ShapeDrawable shape = new ShapeDrawable(new RectShape()); shape.getPaint().setShader(test); SeekBar seekBarFont = (SeekBar)findViewById(R.id.seekbar_font); seekBarFont.setProgressDrawable( (Drawable)shape );
public ColorPaletteDrawable(int color, int width, int height, int mergin) { super(new RectShape()); mRect = new Rect(mergin, mergin, width - mergin, height - mergin); getPaint().setColor(color); }
ShapeDrawable border = new ShapeDrawable(new RectShape()); border.getPaint().setStyle(Style.STROKE); border.getPaint().setColor(Color.BLACK); tv.setBackground(border); content.addView(tv);
ShapeDrawable sd = new ShapeDrawable(new RectShape()); sd.getPaint().setColor(0xFFFFFFFF); sd.getPaint().setStyle(Paint.Style.STROKE); sd.getPaint().setStrokeWidth(1); View shapeView = new View(context); shapeView.setBackground(sd); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(100, 100); params.setMargins(left, top, 0, 0); frameLayout.addView(shapeView, params);
ShapeDrawable sd1 = new ShapeDrawable(new RectShape()); sd1.getPaint().setColor(CommonUtilities.color); sd1.getPaint().setStyle(Style.STROKE); sd1.getPaint().setStrokeWidth(CommonUtilities.stroke); sd1.setPadding(15, 10, 15, 10); sd1.getPaint().setPathEffect( new CornerPathEffect(CommonUtilities.corner)); ln_back.setBackgroundDrawable(sd1);
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);