直接将RefreshProgress添加进xml中当做ImageView就能使用packagecom.example.administrator.superrefresh;importandroid.content.Context;importandroid.graphics.Bitmap;importandroid.graphics.Matrix;importandroid.graphics.drawable.BitmapDrawable;importandroid.util.AttributeSet;importandroid.view.animation.Animation;importandroid.view.animation.LinearInterpolator;importandroid.view.animation.RotateAnimation;importandroid.widget.ImageView;/***CreatedbySLYon2015/9/6.*/publicclassRefreshProgressextendsImageView{privateMatrixm=newMatrix();//匀速加速器privateLinearInterpolatorlir=newLinearInterpolator();publicRefreshProgress(Contextcontext){super(context);}publicRefreshProgress(Contextcontext,AttributeSetattrs){super(context,attrs);}publicvoidchangeAnimation(intnum){m.reset();//Bitmapbitmap=((BitmapDrawable)getResources().getDrawable(R.drawable.loading_rotate)).getBitmap();this.setImageBitmap(bitmap);//显示图像//m.setRotate(num);BitmapnewBitmap=Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),m,true);BitmapDrawablebd=newBitmapDrawable(newBitmap);this.setImageDrawable(bd);//显示新的图像}//控制动画publicvoidAnimation(){RotateAnimationrotate=newRotateAnimation(0,720,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);//默认为0,为-1时一直循环动画rotate.setRepeatCount(-1);//添加匀速加速器rotate.setInterpolator(lir);rotate.setDuration(2000);rotate.setFillAfter(true);this.startAnimation(rotate);}}