Example usage for android.graphics.drawable ShapeDrawable ShapeDrawable

List of usage examples for android.graphics.drawable ShapeDrawable ShapeDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable ShapeDrawable ShapeDrawable.

Prototype

public ShapeDrawable(Shape s) 

Source Link

Document

Creates a ShapeDrawable with a specified Shape.

Usage

From source file:Main.java

public static ShapeDrawable getShapeDrawable(int size, int color) {
    ShapeDrawable circle = new ShapeDrawable(new OvalShape());
    circle.setIntrinsicHeight(size);//  ww w .j a v  a 2  s . c  om
    circle.setIntrinsicWidth(size);
    circle.getPaint().setColor(color);
    return circle;
}

From source file:Main.java

/**
 * @return the Integer value of color/*from   w  w  w.j av  a  2 s . c  o  m*/
 */
public static Drawable createCircleShape(int color) {
    Shape shape = new OvalShape();
    ShapeDrawable drawable = new ShapeDrawable(shape);
    drawable.getPaint().setColor(color);
    return drawable;
}

From source file:Main.java

public static ShapeDrawable getShapeDrawable(int color, int radius) {
    RoundRectShape roundRectShape = new RoundRectShape(
            new float[] { radius, radius, radius, radius, radius, radius, radius, radius }, null, null);
    ShapeDrawable shapeDrawable = new ShapeDrawable(roundRectShape);
    shapeDrawable.getPaint().setColor(color);
    return shapeDrawable;
}

From source file:Main.java

@NonNull
private static Drawable getRippleMask(int color) {
    float[] outerRadii = new float[8];
    // 3 is radius of final ripple,
    // instead of 3 you can give required final radius
    Arrays.fill(outerRadii, 3);//from  w  ww  .  j a  v a2  s  .c om

    RoundRectShape r = new RoundRectShape(outerRadii, null, null);
    ShapeDrawable shapeDrawable = new ShapeDrawable(r);
    shapeDrawable.getPaint().setColor(color);

    return shapeDrawable;
}

From source file:Main.java

/**
 * Make circle drawable for badge background
 *
 * @param color background color/*from ww  w . j a  va2 s .  co  m*/
 * @return return colored circle drawable
 */
static ShapeDrawable makeShapeDrawable(int color) {
    ShapeDrawable badgeBackground = new ShapeDrawable(new OvalShape());
    badgeBackground.setIntrinsicWidth(10);
    badgeBackground.setIntrinsicHeight(10);
    badgeBackground.getPaint().setColor(color);
    return badgeBackground;
}

From source file:Main.java

public static synchronized ShapeDrawable getCircle(final int color) {
    if (color == Color.TRANSPARENT) {
        return null;
    }/*from  www .ja  v a2s.c  o  m*/

    final ShapeDrawable d = new ShapeDrawable(new OvalShape());
    d.getPaint().setColor(color);

    return d;
}

From source file:Main.java

public static synchronized ShapeDrawable getRoundedRect(final int color) {
    if (color == Color.TRANSPARENT) {
        return null;
    }/*from  w  w  w. j a v  a  2s.  co m*/
    int r = 3;
    float[] outerR = new float[] { r, r, r, r, r, r, r, r };
    RoundRectShape rr = new RoundRectShape(outerR, null, null);

    final ShapeDrawable d = new ShapeDrawable(rr);
    d.getPaint().setColor(color);

    return d;
}

From source file:Main.java

private static Drawable getRippleMask(int color) {
    ShapeDrawable shapeDrawable = new ShapeDrawable(new RectShape());
    shapeDrawable.getPaint().setColor(color);
    return shapeDrawable;
}

From source file:com.hellofyc.base.util.ViewUtils.java

public static ShapeDrawable make(int size, int color) {
    ShapeDrawable indicator = new ShapeDrawable(new OvalShape());
    indicator.setIntrinsicWidth(size);/*from ww  w. j av  a2  s  .c om*/
    indicator.setIntrinsicHeight(size);
    indicator.getPaint().setColor(color);
    return indicator;
}

From source file:com.com.mytoolsproject.CircleImageView.java

CircleImageView(Context context, int color) {
    super(context);
    final float density = getContext().getResources().getDisplayMetrics().density;
    final int shadowYOffset = (int) (density * Y_OFFSET);
    final int shadowXOffset = (int) (density * X_OFFSET);

    mShadowRadius = (int) (density * SHADOW_RADIUS);

    ShapeDrawable circle;//from  www.  j a  v  a 2  s.c  o  m
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {
        OvalShape oval = new OvalShadow(mShadowRadius);
        circle = new ShapeDrawable(oval);
        ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
        circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
        final int padding = mShadowRadius;
        // set padding so the inner image sits correctly within the shadow.
        setPadding(padding, padding, padding, padding);
    }
    circle.getPaint().setColor(color);
    setBackgroundDrawable(circle);
}