动感的Sheet(选择器)AndroidSweetSheet_安卓5.0 Action Sheet
2015-08-25 12:43:10  By: dwtedx

分享一个Sheet选择器、AndroidSweetSheet一个富有动感的 Sheet(选择器)、效果是使用Android5.0 的动画特效、弹性动画、非常好看、Demo是采用Android Studio 开发的、如果没有安装Android Studio的哥们可以下载查看效果、效果图如下

AndroidSweetSheet


SweetViewshow()

public void show() {
    mStatus=Status.STATUS_SMOOTH_UP;


    if(mAnimationListener != null) {
        mAnimationListener.onStart();
        this.postDelayed(new Runnable() {
            @Override
            public void run() {

                mAnimationListener.onContentShow();
            }
        }, 600);
    }

    ValueAnimator valueAnimator=ValueAnimator.ofInt(0, mMaxArcHeight);
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int value = (int) animation.getAnimatedValue();
            mArcHeight = value;

            if (value == mMaxArcHeight) {
                duang();
            }
            invalidate();
        }
    });
    valueAnimator.setDuration(800);
    valueAnimator.setInterpolator(new AccelerateInterpolator());
    valueAnimator.start();

}


SweetViewduang()

public void duang(){
    mStatus=Status.STATUS_DOWN;
    ValueAnimator valueAnimator=ValueAnimator.ofInt(mMaxArcHeight,0);
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mArcHeight = (int) animation.getAnimatedValue();
            invalidate();
        }
    });
    valueAnimator.addListener(new SimpleAnimationListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mAnimationListener != null) {
                mAnimationListener.onEnd();
            }
        }
    });
    valueAnimator.setDuration(500);
    valueAnimator.setInterpolator(new OvershootInterpolator(4f));
    valueAnimator.start();
}


SweetViewdrawBG()

private void drawBG(Canvas canvas) {
    mPath.reset();
    int currentPointY=0;
    switch (mStatus){
        case NONE:
            currentPointY = mMaxArcHeight;
            break;
        case  STATUS_SMOOTH_UP:
        case STATUS_UP:
            currentPointY=getHeight()-(int) ((getHeight()-mMaxArcHeight)* Math.min(1,(mArcHeight-mMaxArcHeight /4 )* 2.0 / mMaxArcHeight * 1.3));
            break;
        case STATUS_DOWN:
            currentPointY = mMaxArcHeight;
            break;
    }
    mPath.moveTo(0, currentPointY);
    mPath.quadTo(getWidth() / 2, currentPointY - mArcHeight, getWidth(), currentPointY);
    mPath.lineTo(getWidth(), getHeight());
    mPath.lineTo(0, getHeight());
    mPath.lineTo(0, currentPointY);
    canvas.drawPath(mPath, mPaint);
}


最后给贴上Demo的源代码、希望对大家有用、有兴趣的哥们可以下载看看

源代码下载链接: http://dwtedx.com/download.html?bdkey=s/1pJsu6RD 密码: xkma

若资源对你有帮助、浏览后有很大收获、不妨小额打赏我一下、你的鼓励是维持我不断写博客最大动力

想获取DD博客最新代码、你可以扫描下方的二维码、关注DD博客微信公众号(ddblogs)

或者你也可以关注我的新浪微博、了解DD博客的最新动态:DD博客官方微博(dwtedx的微博)

如对资源有任何疑问或觉得仍然有很大的改善空间、可以对该博文进行评论、希望不吝赐教

为保证及时回复、可以使用博客留言板给我留言: DD博客留言板(dwtedx的留言板)

感谢你的访问、祝你生活愉快、工作顺心、欢迎常来逛逛


快速评论


技术评论

DD记账
top
+