答案 0 :(得分:0)
我创建了一个通过对话框扩展的自定义类。可能这对你有帮助
public class CProgressDialog extends Dialog {
private ImageView iv;
public CProgressDialog(Context context) {
super(context, R.style.TransparentProgressDialog);
WindowManager.LayoutParams wlmp = getWindow().getAttributes();
wlmp.gravity = Gravity.CENTER_HORIZONTAL;
getWindow().setAttributes(wlmp);
setTitle(null);
setCancelable(false);
setOnCancelListener(null);
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
iv = new ImageView(context);
iv.setImageResource(R.drawable.spiner_green);
layout.addView(iv, params);
addContentView(layout, params);
}
@Override
public void show() {
super.show();
RotateAnimation anim = new RotateAnimation(0.0f, 360.0f,
Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF,
.5f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(2000);
iv.setAnimation(anim);
iv.startAnimation(anim);
}