自定义加速球效果

一个自定义控件:

地址:

git:https://github.com/guoGavin/CustomAccelerateBall

csdn:http://download.csdn.net/detail/jiguangcanhen/8687305


accelerate ball,加速球效果,也就是圆形的ProgressBar的效果。

效果图

录制效果不是很好

Screenshot

功能

  • 可以设置目标位置,让它自己加速到特定位置。
  • 可以设置不适用加速的动画效果,直接设置到特定位置。
  • 可以设置是否显示Percent。
  • 可以设置刷新速度,RefreshSpeed。
  • 可以设置加速动画涨幅,Speed。
  • 可以设置加速过程监听,每次变化监听回调,加速结束回调,AccelerateBallUpdateListener。

layout

<com.test.gavinguo.customaccelerateball.AccelerateBallView
        android:id="@+id/ball"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_marginTop="50dp"
        android:layout_gravity="center_horizontal"/>

展示类型

public enum GalleryType{
        NoneAnimationAndPercent,//没有动画和百分比文字
        NoneAnimationHavePercent,//没有动画但是有文本
        AnimationOnly,//只有动画
        AnimationAndPercent,//具有动画和百分比,default
    }

动画涨幅

public enum Speed{
        slow,//低速
        medium,//中速,default
        fast,//高速
        superFast,//超高速
        random,//随机速度
    }

刷新速度

public enum RefreshSpeed{
        slow,//低速
        medium,//中速,default
        fast,//高速
        superFast,//超高速
    }

过程监听

public interface AccelerateBallUpdateListener{
        /**
         * 每次变化
         * @param currentPercent 当前百分比
         */
        void updateLeveUp(int currentPercent);

        /**
         * 上涨结束调用
         * @param endPercent 结束时候的百分比
         */
        void endLeveUp(int endPercent);
    }

设置参数以及启动

  ball = (AccelerateBallView) findViewById(R.id.ball);
  ball.setSpeedType(AccelerateBallView.Speed.superFast);
  ball.setRefreshSpeedType(AccelerateBallView.RefreshSpeed.superFast);
  ball.setGalleryType(AccelerateBallView.GalleryType.AnimationAndPercent);
  ball.setAccelerateBallUpdateListener(new AccelerateBallView.AccelerateBallUpdateListener() {
      @Override
      public void updateLeveUp(int currentPercent) {
          //do nothing
      }

      @Override
      public void endLeveUp(int endPercent) {
          //do nothing
      }
  });
  start.setOnClickListener(this);
  ball.setTotalLevel(totalLevel);

Total可以不停的去设置,加速球最终会停止在最后设置的位置。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值