Example usage for android.graphics.drawable ShapeDrawable getPaint

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

Introduction

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

Prototype

public Paint getPaint() 

Source Link

Document

Returns the Paint used to draw the shape.

Usage

From source file:com.scott.lib.widget.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;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {//  w ww .j a  v a  2 s  .c om
        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);
    //noinspection deprecation
    setBackgroundDrawable(circle);
}

From source file:me.williamhester.reddit.ui.views.CircleImageView.java

public CircleImageView(Context context, AttributeSet attrs, int color, final float radius) {
    super(context, attrs);
    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;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {//from   www .  j  a v a2  s .  c  om
        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 = (int) mShadowRadius;
        // set padding so the inner image sits correctly within the shadow.
        setPadding(padding, padding, padding, padding);
    }
    circle.getPaint().setColor(color);
    setBackground(circle);
    //        setImageDrawable(getResources().getDrawable(R.drawable.ic_action_up));
}

From source file:com.jtech.view.CircleImageView.java

@SuppressWarnings("deprecation")
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;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {//w  w  w.jav a2 s.c om
        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);
}

From source file:com.learn.mobile.customview.DCircleImageView.java

public DCircleImageView(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;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {// w  ww. j av a  2s .com
        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);
}

From source file:org.srr.dev.view.refreshlayout.RefreshCircleImageView.java

@SuppressWarnings("deprecation")
public RefreshCircleImageView(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;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {//  ww w  .  ja  v a2s  .c o m
        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);
}

From source file:com.usabusi.swiperefreshlayoutupdown.view.CircleImageViewUpDown.java

public CircleImageViewUpDown(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;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {/*from  www .ja  v  a 2 s  .  c  o  m*/
        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 = (int) mShadowRadius;
        // set padding so the inner image sits correctly within the shadow.
        setPadding(padding, padding, padding, padding);
    }
    circle.getPaint().setColor(color);
    setBackgroundDrawable(circle);
    //        int sdk = android.os.Build.VERSION.SDK_INT;
    //        if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
    //            setBackgroundDrawable(circle);
    //        } else {
    //            setBackground(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;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {/*  w  w w . j  a  v  a2s  .  c o  m*/
        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.wenyu.loadingrecyclerview.CircleImageView.java

private void init() {
    final float density = getContext().getResources().getDisplayMetrics().density;
    final int diameter = (int) (20 * density * 2);
    final int shadowYOffset = (int) (density * Y_OFFSET);
    final int shadowXOffset = (int) (density * X_OFFSET);

    mShadowRadius = (int) (density * SHADOW_RADIUS);

    ShapeDrawable circle;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {/*from w ww.jav  a  2s  . c o  m*/
        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(0xFFFAFAFA);
    setBackgroundDrawable(circle);
}

From source file:com.chronosystems.nearbyapp.components.loader.CircleImageView.java

final protected void init(int color, float radius) {
    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;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {//from w  ww  .  ja  v a 2  s  .c  o  m
        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 = (int) 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.tian.sharebox.widget.CircleLoadingImageView.java

public CircleLoadingImageView(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;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {/*  w w  w.  j  ava2  s. c  om*/
        OvalShape oval = new CircleLoadingImageView.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 = (int) mShadowRadius;
        // set padding so the inner image sits correctly within the shadow.
        setPadding(padding, padding, padding, padding);
    }
    circle.getPaint().setColor(color);
    setBackgroundDrawable(circle);
}