AnimCheckBox按钮点击动画效果《IT蓝豹》
AnimCheckBox按钮点击动画效果《IT蓝豹》
抉择很难 发表于3年前
AnimCheckBox按钮点击动画效果《IT蓝豹》
  • 发表于 3年前
  • 阅读 48
  • 收藏 1
  • 点赞 0
  • 评论 0

移动开发云端新模式探索实践 >>>   

摘要: AnimCheckBox按钮点击动画效果

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);
    }

 

运行效果:

相关代码

  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 6
博文 51
码字总数 26157
×
抉择很难
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: