仿饿了么加载动画

饿了么
使用:

loadingView.addBitmap(R.mipmap.v4);

or

loadingView.addBitmap(bitmap);

or

loadingView.addBitmaps(mBitmapList);

//set the shadow color

loadingView.setShadowColor(Color.LTGRAY);

//set the duration of animation

loadingView.setDuration(800);

loadingView.start();

原理:

其实很简单,首先说需要提供几个方法添加图片

addBitmap(bitmap)

addBitmap(resId)

addBitmaps(mBitmapList)

然后new 一个无限循环的ValueAnimator ,在数值不断变化的时候不断postInvalide(); 画下面的椭圆和bitmap

valueAnimator的时长即一个bitmap弹起落下的时间, 这就是一个周期。在一个周期结束后更换图片,也就是:

animator.addListener(new AnimatorListenerAdapter() {    

@Override    

public void onAnimationStart(Animator animation) {       

//重置index        

mCurrentIndex = 0;       

mCurrentBitmap = mBitmapList.get(mCurrentIndex);    

}    

@Override    

public void onAnimationRepeat(Animator animation) {        

if(mBitmapList != null && mBitmapList.size() > 0){            

mCurrentIndex ++;            

if(mCurrentIndex >= mBitmapList.size()) {                

mCurrentIndex = 0;            

}            

mCurrentBitmap = mBitmapList.get(mCurrentIndex);       

}    

}});

demo下载http://download.csdn.net/detail/qq_35549248/9846425

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值