Android 等待过程中的转圈动画

 效果:(下面转圈的小圆圈)

  Android 等待过程中的转圈动画_第1张图片

private CustomProgressDialog progressDialog;

//实例化自定义CustomProgressDialog
progressDialog = new CustomProgressDialog(context, R.style.progressDialog);
//设置不可点击外边取消动画
progressDialog.setCanceledOnTouchOutside(false);
//动画显示
progressDialog.show();


 

样式:progressDialog

 

//自定义CustomProgressDialog
public class CustomProgressDialog extends ProgressDialog {

   private Context context;

   public CustomProgressDialog(Context context) {
      super(context);
      this.context = context;
   }

   public CustomProgressDialog(Context context, int theme) {
      super(context, theme);
      this.context = context;
   }

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      View view = View.inflate(getContext(), R.layout.customprogressdialog, null);
      ImageView progress_img = (ImageView)view. findViewById(R.id.iv_bg);
      Animation operatingAnim = AnimationUtils.loadAnimation(getContext(), R.anim.anim_upload_progress);
      //LinearInterpolator lin = new LinearInterpolator();
     // operatingAnim.setInterpolator(lin);
      progress_img.setAnimation(operatingAnim);
      setContentView(view);
   }  
   
   @Override
   public void show() {
      //setCancelable(false);;
      super.show();
   }
  
}

//布局:customprogressdialog
 




 
       //转圈的图片
        

        
    

//动画:anim_upload_progress

//在正中心,在1秒内,从0度转到360度,不停止


    

你可能感兴趣的:(Android 等待过程中的转圈动画)