自定义加速球效果
一個自定義控件:
地址:
git:https://github.com/guoGavin/CustomAccelerateBall
csdn:http://download.csdn.net/detail/jiguangcanhen/8687305
accelerate ball,加速球效果,也就是圓形的ProgressBar的效果。
效果圖
錄制效果不是很好
功能
- 可以設置目標位置,讓它自己加速到特定位置。
- 可以設置不適用加速的動畫效果,直接設置到特定位置。
- 可以設置是否顯示Percent。
- 可以設置刷新速度,RefreshSpeed。
- 可以設置加速動畫漲幅,Speed。
- 可以設置加速過程監聽,每次變化監聽回調,加速結束回調,AccelerateBallUpdateListener。
layout
<com.test.gavinguo.customaccelerateball.AccelerateBallViewandroid: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,//中速,defaultfast,//高速superFast,//超高速random,//隨機速度}刷新速度
public enum RefreshSpeed{slow,//低速medium,//中速,defaultfast,//高速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() {@Overridepublic void updateLeveUp(int currentPercent) {//do nothing}@Overridepublic void endLeveUp(int endPercent) {//do nothing}});start.setOnClickListener(this);ball.setTotalLevel(totalLevel);Total可以不停的去設置,加速球最終會停止在最后設置的位置。
總結
- 上一篇: 设备的分配与调度简单方案_连铸生产调度与
- 下一篇: [学习笔记]上下界网络流