List of usage examples for android.graphics.drawable ShapeDrawable setShape
public void setShape(Shape s)
From source file:com.saulmm.cui.OrderDialogFragment.java
private Drawable createProductImageDrawable(Product product) { final ShapeDrawable background = new ShapeDrawable(); background.setShape(new OvalShape()); background.getPaint().setColor(ContextCompat.getColor(getContext(), product.color)); final BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), product.image)); final LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { background, bitmapDrawable }); final int padding = (int) getResources().getDimension(R.dimen.spacing_huge); layerDrawable.setLayerInset(1, padding, padding, padding, padding); return layerDrawable; }
From source file:ticwear.design.widget.FloatingActionButton.java
Drawable createShapeDrawable() { ShapeDrawable d = new ShapeDrawable(); d.setShape(new OvalShape()); d.getPaint().setColor(Color.WHITE); return d;/* w w w. j a va 2 s .c om*/ }
From source file:de.uni_weimar.mheinz.androidtouchscope.display.ScopeView.java
private void initDrawable(ShapeDrawable drawable, Path path, int color, int width, int height) { path.moveTo(0, 0);//from ww w. j a v a 2 s . co m drawable.setShape(new PathShape(path, width, height)); drawable.getPaint().setStyle(Paint.Style.STROKE); drawable.getPaint().setColor(color); drawable.setBounds(0, 0, width, height); setLayerType(LAYER_TYPE_SOFTWARE, drawable.getPaint()); }
From source file:de.uni_weimar.mheinz.androidtouchscope.display.ScopeView.java
private void initGridV(ShapeDrawable drawable, Path path, int color, int width, int height) { path.rewind();/*from ww w . j a va2s . c o m*/ float cellWidth = width / NUM_COLUMNS; for (int i = 0; i < NUM_COLUMNS; ++i) { path.moveTo(i * cellWidth, 0); path.lineTo(i * cellWidth, height); } float offset = NUM_ROWS * 5; drawable.setShape(new PathShape(path, width, height)); drawable.getPaint().setStyle(Paint.Style.STROKE); drawable.getPaint().setColor(color); drawable.getPaint().setPathEffect(new DashPathEffect(new float[] { 1, (height - offset) / offset }, 0)); drawable.setBounds(0, 0, width, height); }
From source file:de.uni_weimar.mheinz.androidtouchscope.display.ScopeView.java
private void initGridH(ShapeDrawable drawable, Path path, int color, int width, int height) { path.rewind();//from w ww .j a va 2s . c o m float cellHeight = height / NUM_ROWS; for (int i = 0; i < NUM_ROWS; ++i) { path.moveTo(0, i * cellHeight); path.lineTo(width, i * cellHeight); } float offset = NUM_COLUMNS * 5; drawable.setShape(new PathShape(path, width, height)); drawable.getPaint().setStyle(Paint.Style.STROKE); drawable.getPaint().setColor(color); drawable.getPaint().setPathEffect(new DashPathEffect(new float[] { 1, (width - offset) / offset }, 0)); drawable.setBounds(0, 0, width, height); }