码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-10-21 12:47:13      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

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

 

运行效果:

  • 技术分享

相关代码

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

标签:

原文地址:http://my.oschina.net/u/2461971/blog/519747

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!