使用:
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.youkuaiyun.com/detail/qq_35549248/9846425