Example usage for android.graphics Outline offset

List of usage examples for android.graphics Outline offset

Introduction

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

Prototype

public void offset(int dx, int dy) 

Source Link

Document

Offsets the Outline by (dx,dy)

Usage

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

public JellyHeader(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setWillNotDraw(false);/* w  w  w .j a va2s  .  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));
        }
    }
}