Example usage for android.graphics.drawable.shapes OvalShape OvalShape

List of usage examples for android.graphics.drawable.shapes OvalShape OvalShape

Introduction

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

Prototype

public OvalShape() 

Source Link

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 av  a 2  s.  c  o m*/
    circle.setIntrinsicWidth(size);
    circle.getPaint().setColor(color);
    return circle;
}

From source file:Main.java

/**
 * @return the Integer value of color/* w  ww .  j a  va  2s. c om*/
 */
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

/**
 * Make circle drawable for badge background
 *
 * @param color background color//  w  ww  .  j  av  a2  s . c o 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 ww  w  . j  ava 2s .co m

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

    return d;
}

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);// w  ww.ja  v  a  2 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  ww  w. j  a  va 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);
}

From source file:udacity.lzy.test.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  ww w .ja  v  a 2s.co  m*/
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {
        OvalShape oval = new CircleImageView.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);
}

From source file:com.congxiaoyao.xber_admin.widget.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   w w w  .ja  va 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);
    ViewCompat.setBackground(this, circle);
}

From source file:org.alex.refreshlayout.view.CircleImageView.java

public 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;/*ww w  .  j a v  a  2 s.co 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);
    ViewCompat.setBackground(this, circle);
}

From source file:com.suyou.media.ui.widget.refresh.CircleImageView.java

public CircleImageView(Context context, int color, final float radius) {
    super(context);
    final float density = getContext().getResources().getDisplayMetrics().density;
    final int diameter = (int) (radius * density * 2);
    final int shadowYOffset = (int) (density * Y_OFFSET);
    final int shadowXOffset = (int) (density * X_OFFSET);
    mShadowRadius = (int) (density * SHADOW_RADIUS);
    ShapeDrawable circle;//from   ww  w .  jav  a2  s.c  om
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {
        OvalShape oval = new OvalShadow(mShadowRadius, diameter);
        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);
}