点子出自dribbble
swift版本
android版本
以下是效果展示

shot.png shot1.gif shot2.gif shot3.gif

纸条模式的代码

private void drawPaperSlip(Canvas canvas) {        Path PaperSlip = new Path();        float paperSlipwidth = rectFPaper.width() / paperSlipCount;        float paperSlipspace = paperSlipwidth / 7f;        float animatedValue = mAnimatedValue;        mPaint.setColor(paperColor);        for (int i = 0; i < randomQuadHighs.size(); i++) {            PaperSlip.reset();            PaperSlip.moveTo(rectFPaper.left + i * paperSlipwidth + paperSlipspace,                    rectFPaper.bottom            );            PaperSlip.lineTo(rectFPaper.left + (i + 1) * paperSlipwidth - paperSlipspace,                    rectFPaper.bottom            );            float paperSlipHigh = rectFPaper.height() * 2 / 3f                    + rectFPaper.height() / 3f * randomHighs.get(i);            float randomQuadWidth = this.randomQuadWidths.get(i) * paperSlipspace * 2.5f * animatedValue;            if (i % 2 == 0) {                randomQuadWidth = randomQuadWidth * -1;            }            float randomQuadHigh = this.randomQuadHighs.get(i) * paperSlipHigh * animatedValue;            PaperSlip.quadTo(                    rectFPaper.left + (i + 1) * paperSlipwidth - paperSlipspace -                            randomQuadWidth,                    rectFPaper.bottom + randomQuadHigh,                    rectFPaper.left + (i + 1) * paperSlipwidth - paperSlipspace,                    rectFPaper.bottom + paperSlipHigh            );            PaperSlip.lineTo(rectFPaper.left + (i) * paperSlipwidth + paperSlipspace,                    rectFPaper.bottom + paperSlipHigh            );            PaperSlip.quadTo(                    rectFPaper.left + i * paperSlipwidth + paperSlipspace -                            randomQuadWidth,                    rectFPaper.bottom + randomQuadHigh,                    rectFPaper.left + i * paperSlipwidth + paperSlipspace,                    rectFPaper.bottom            );            PaperSlip.close();            canvas.drawPath(PaperSlip, mPaint);        }    }

纸片模式

 private void drawPaperPiece(Canvas canvas) {        if (mAnimatedValue == 0)            return;        float paperPiecewidth = rectFPaper.width() / paperSlipCount;        Path paperPiece = new Path();        for (int i = 0; i < PaperPiecerandAngle.size(); i++) {            int angle = (int) (PaperPiecerandAngle.get(i) * 360);            angle = (int) (angle + 180 * mAnimatedValue);            float radius = paperPiecewidth * 0.8f;            if (PaperPiecerandRadius.get(i) < 0.3f) {                PaperPiecerandRadius.set(i,0.3f);            }            radius = radius * PaperPiecerandRadius.get(i);            float centerX = mPaddingLR * 3 + (getMeasuredWidth() - 6 * mPaddingLR) * PaperPiecerandX.get(i);            float centerY = getMeasuredHeight() / 3 * PaperPiecerandY.get(i) + getMeasuredHeight() / 3                    + mAnimatedValue * getMeasuredHeight() / 3;            if (PaperPiecerandRadius.get(i) >= 0.3f && PaperPiecerandRadius.get(i) <= 0.4f) {                centerY = getMeasuredHeight() / 3 * PaperPiecerandY.get(i) + getMeasuredHeight() / 3                        + mAnimatedValue * getMeasuredHeight() / 3 * 2.8f;            } else if (PaperPiecerandRadius.get(i) > 0.4f && PaperPiecerandRadius.get(i) <= 0.5f) {                centerY = getMeasuredHeight() / 3 * PaperPiecerandY.get(i) + getMeasuredHeight() / 3                        + mAnimatedValue * getMeasuredHeight() / 3 * 2.6f;            } else if (PaperPiecerandRadius.get(i) > 0.5f && PaperPiecerandRadius.get(i) <= 0.6f) {                centerY = getMeasuredHeight() / 3 * PaperPiecerandY.get(i) + getMeasuredHeight() / 3                        + mAnimatedValue * getMeasuredHeight() / 3 * 2.4f;            } else if (PaperPiecerandRadius.get(i) > 0.6f && PaperPiecerandRadius.get(i) <= 0.7f) {                centerY = getMeasuredHeight() / 3 * PaperPiecerandY.get(i) + getMeasuredHeight() / 3                        + mAnimatedValue * getMeasuredHeight() / 3 * 2.2f;            } else if (PaperPiecerandRadius.get(i) > 0.7f && PaperPiecerandRadius.get(i) <= 0.8f) {                centerY = getMeasuredHeight() / 3 * PaperPiecerandY.get(i) + getMeasuredHeight() / 3                        + mAnimatedValue * getMeasuredHeight() / 3 * 2.4f;            } else if (PaperPiecerandRadius.get(i) > 0.8f && PaperPiecerandRadius.get(i) <= 0.9f) {                centerY = getMeasuredHeight() / 3 * PaperPiecerandY.get(i) + getMeasuredHeight() / 3                        + mAnimatedValue * getMeasuredHeight() / 3 * 2.6f;            } else if (PaperPiecerandRadius.get(i) > 0.9f) {                centerY = getMeasuredHeight() / 3 * PaperPiecerandY.get(i) + getMeasuredHeight() / 3                        + mAnimatedValue * getMeasuredHeight() / 3 * 2.8f;            }            float x = (float) ((radius) * Math.cos(angle * Math.PI / 180f));            float y = (float) ((radius) * Math.sin(angle * Math.PI / 180f));            paperPiece.reset();            paperPiece.moveTo(centerX - x,                    centerY - y            );            int angleBig = 0;            if (PaperPiecerandX.get(i) > 0.7f) {                angleBig = (int) (180 * 0.7f);            } else if (PaperPiecerandX.get(i) < 0.3f) {                angleBig = (int) (180 * 0.3f);            } else {                angleBig = (int) (180 * PaperPiecerandX.get(i));            }            int angleSmall = 180 - angleBig;            angle = angle + angleBig;            x = (float) ((radius) * Math.cos(angle * Math.PI / 180f));            y = (float) ((radius) * Math.sin(angle * Math.PI / 180f));            paperPiece.lineTo(centerX - x,                    centerY - y            );            angle = angle + angleSmall;            x = (float) ((radius) * Math.cos(angle * Math.PI / 180f));            y = (float) ((radius) * Math.sin(angle * Math.PI / 180f));            paperPiece.lineTo(centerX - x,                    centerY - y            );            angle = angle + angleBig;            x = (float) ((radius) * Math.cos(angle * Math.PI / 180f));            y = (float) ((radius) * Math.sin(angle * Math.PI / 180f));            paperPiece.lineTo(centerX - x,                    centerY - y            );            angle = angle + angleSmall;            x = (float) ((radius) * Math.cos(angle * Math.PI / 180f));            y = (float) ((radius) * Math.sin(angle * Math.PI / 180f));            paperPiece.lineTo(centerX - x,                    centerY - y            );            paperPiece.close();            int color = (Integer) evaluator.evaluate(PaperPiecerandRadius.get(i),                    Color.rgb(180, 180, 180), paperColor            );            mPaint.setColor(color);            canvas.drawPath(paperPiece, mPaint);        }        mPaint.setColor(paperColor);    }

使用方式xml

java

       mPaperShredderView.setShrededType(PaperShredderView.SHREDEDTYPE.Piece);//纸片效果和纸条效果       mPaperShredderView.setSherderProgress(false);       mPaperShredderView.setTitle("清除数据");       mPaperShredderView.setTextColor(Color.BLACK);       mPaperShredderView.setPaperColor(Color.BLACK);       mPaperShredderView.setBgColor(Color.WHITE);       mPaperShredderView.setTextShadow(false);       mPaperShredderView.setPaperEnterColor(Color.BLACK);       mPaperShredderView.startAnim(1000);       mPaperShredderView.stopAnim();

如果觉得还不错,去github给我点颗星吧^^
代码下载

更多相关文章

  1. Android(安卓)Activity界面切换添加动画特效
  2. TabHost与RadioGroup结合完成的菜单【带效果图】5个Activity
  3. Android(安卓)的 supportdesign
  4. android 音效处理 (2)
  5. Android(安卓)Activity界面切换添加动画特效
  6. android 音效处理 (2)
  7. SlidingMenu和ActionBarSherlock结合做出出色的App布局,Facebook
  8. Android(安卓)实现View中添加子元素的动态效果
  9. Android(安卓)5.x特性概览二

随机推荐

  1. android面试一些常见的问题
  2. Android横竖屏总结全
  3. android的binder机制研究(C++部分)
  4. 【Android(安卓)UI】ListView系列一(基础
  5. Android使用Cordova框架开发Android(安卓
  6. android资源引用
  7. Android实现高定制化日历控件
  8. Android(安卓)NFC 对sim卡读写注意事项
  9. Android虚拟机与Java虚拟机——两种虚拟
  10. android与html5的交互——数据库操作,UI操