Example usage for android.graphics Outline setConvexPath

List of usage examples for android.graphics Outline setConvexPath

Introduction

In this page you can find the example usage for android.graphics Outline setConvexPath.

Prototype

public void setConvexPath(@NonNull Path convexPath) 

Source Link

Document

Sets the Constructs an Outline from a android.graphics.Path#isConvex() convex path .

Usage

From source file:com.rks.musicx.misc.widgets.DiagonalLayout.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override//from   www  . j a v a 2 s .  c o  m
public ViewOutlineProvider getOutlineProvider() {
    return new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            outline.setConvexPath(outlinePath);
        }
    };
}

From source file:com.shizhefei.view.coolrefreshview.header.JellyHeader.java

public JellyHeader(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setWillNotDraw(false);/*  ww  w.java2  s  .  c  o m*/

    defaultMinHeight = Utils.dipToPix(context, 208);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);

    mPath = new Path();

    showLoadingAnimation = new AlphaAnimation(0, 1);
    showLoadingAnimation.setDuration(300);
    showLoadingAnimation.setInterpolator(new AccelerateInterpolator());

    hideLoadingAnimation = new AlphaAnimation(1, 0);
    hideLoadingAnimation.setDuration(300);
    hideLoadingAnimation.setInterpolator(new DecelerateInterpolator());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mViewOutlineProvider = new ViewOutlineProvider() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void getOutline(View view, Outline outline) {
                if (mPath.isConvex())
                    outline.setConvexPath(mPath);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
                    outline.offset(0, totalDistance() - currentDistance);
                }
            }
        };
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setElevation(Utils.dipToPix(context, 4));
        }
    }
}