public class LoadingDialog { /** * 旋转动画的时间 */ static final int ROTATION_ANIMATION_DURATION = 1200; /** * 动画插值 */ static final Interpolator ANIMATION_INTERPOLATOR = new LinearInterpolator(); Window window; Dialog d; private ImageView imageView; // private Animation animation; private TextView textView; private Context context; @SuppressWarnings("deprecation") public LoadingDialog(Context context) { this.context = context; View view = View.inflate(context, R.layout.common_loadingdialog, null); imageView = (ImageView) view.findViewById(R.id.imageView); textView = (TextView) view.findViewById(R.id.load_text); AnimationDrawable ad = (AnimationDrawable) context.getResources().getDrawable(R.drawable.anim_loading_progress_round); imageView.setBackgroundDrawable(ad); ad.start(); d = new Dialog(context, R.style.dialog);// 加入样式 d.setCanceledOnTouchOutside(false); window = d.getWindow(); window.setGravity(Gravity.CENTER); window.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } public void show() { if (null != d && !d.isShowing()) { d.show(); } } public void show(String content) { if (null != d && !d.isShowing()) { textView.setText(content); d.show(); } } public void dismiss() { if (d != null) { d.dismiss(); } } public void setCancel() { if (d != null) { d.setCancelable(false); } } }
加载动画的实现
最新推荐文章于 2022-08-22 16:34:12 发布