AnimCheckBox按钮点击动画效果《IT蓝豹》

不想你离开。 提交于 2019-12-02 14:53:28

AnimCheckBox按钮点击动画效果

AnimCheckBox按钮点击动画效果,点击选中后勾选框选择效果,很不错的动画功能。
项目来源:https://github.com/lguipeng/AnimCheckBox
本项目主要介绍:
本项目主要自定义AnimCheckBox 集成View,提供选择的监听接口OnCheckedChangeListener
主要由drawCircle()方法和drawHook(Canvas canvas);
  private void drawCircle(Canvas canvas){
        initDrawStrokeCirclePaint();
        canvas.drawArc(mRectF, 202, mSweepAngle, false, mPaint);
        initDrawAlphaStrokeCirclePaint();
        canvas.drawArc(mRectF, 202, mSweepAngle - 360, false, mPaint);
        initDrawInnerCirclePaint();
        canvas.drawArc(mInnerRectF, 0, 360, false, mPaint);
    }

    private void drawHook(Canvas canvas){
        if (mHookOffset == 0)
            return;
        initDrawHookPaint();
        mPath.reset();
        float offset;
        if (mHookOffset <= (2 * size/3 - mHookStartY - mBaseLeftHookOffset)){
            mPath.moveTo(mBaseLeftHookOffset, mBaseLeftHookOffset + mHookStartY);
            mPath.lineTo(mBaseLeftHookOffset + mHookOffset, mBaseLeftHookOffset + mHookStartY + mHookOffset);
        }else if (mHookOffset <= mHookSize){
            mPath.moveTo(mBaseLeftHookOffset, mBaseLeftHookOffset + mHookStartY);
            mPath.lineTo(2 * size / 3 - mHookStartY, 2 * size / 3);
            mPath.lineTo(mHookOffset + mBaseLeftHookOffset,
                    2 * size/3 - (mHookOffset - (2 * size/3 - mHookStartY - mBaseLeftHookOffset)));
        }else {
            offset = mHookOffset - mHookSize;
            mPath.moveTo(mBaseLeftHookOffset + offset, mBaseLeftHookOffset + mHookStartY + offset);
            mPath.lineTo(2 * size / 3 - mHookStartY, 2 * size / 3);
            mPath.lineTo(mHookSize + mBaseLeftHookOffset + offset,
                    2 * size/3 - (mHookSize - (2 * size/3 - mHookStartY - mBaseLeftHookOffset) + offset));
        }
        canvas.drawPath(mPath, mPaint);
    }

 

运行效果:

相关代码

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!