翻翻git之---自定义邮件发送按钮SendButton(流程分析,实现思路可以学习下)

本文介绍了一个自定义的Git组件SendButton,分析了其实现过程。通过继承View并设置动画模式、画笔等,实现了一个包含圆角、三角形元素的按钮。虽然没有提供XML设置方法,但提供了源码供学习者参考。作者提醒,由于持续刷UI,长时间动画可能会导致轻微卡顿。
摘要由CSDN通过智能技术生成

转载请注明出处:王亟亟的大牛之路

距离过年还有1天,继续这一系列的git翻料之旅。

昨天的工具类真的很棒,这里再推崇一下 传送门:http://blog.csdn.net/ddwhan0123/article/details/50624061 (实际去体验的小伙伴都说好)

今天上一个自定义的Button:SendButton

效果:

这里写图片描述

这里写图片描述

比较建议把代码抠出来因为内容不多,一个类就画完了

地址:https://github.com/ddwhan0123/SendButton

因为内容不多,我们就来分析下

public class SendButton extends View

31行,继承View而不是ViewGroup(也就是不像一个Layout为底板 当中画东西了,纯画)

    int flag = 0;
    Point a, b, c, d, e;
    Path mOutlinePath, mPlanePath;
    int mButtonColor, mButtonSide, mBorderStrokeWidth, mPlaneStrokeWidth, mPlaneColor;
    Paint mBackgroundPaint, mPlanePaint;
    ValueAnimator mPlaneAnimator;
    long mDuration;
    AnimationType mAnimationType;

35-42,定义了一系列变量,动画模式啊,持续时间啊,画笔啊,尺寸什么的

public SendButton(Context context, AttributeSet attrs)
    {
        super(context, attrs);

        TypedArray a = context.getTheme().obtainStyledAttributes(
                attrs,
                R.styleable.SendButton,
                0, 0);
        try
        {
            mButtonColor = a.getColor(R.styleable.SendButton_buttonColor, Color.WHITE);
            mButtonSide = a.getDimensionPixelSize(R.styleable.SendButton_buttonSide, 200);
            mBorderStrokeWidth = a.getInteger(R.styleable.SendButton_borderStrokeWidth, 5);
            mPlaneStrokeWidth = a.getInteger(R.styleable.SendButton_planeStrokeWidth, 5);
            mPlaneColor = a.getColor(R.styleable.SendButton_planeColor, getResources().getColor(R.color
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值