Loading images looks boring in "Android" with same arrangement of circle with Loading image. So here we run with some custom process dialog that will show some cool things. For doing or implementing the same you can use the below code.
public class TransparentProgressDialog extends Dialog {
private ImageView iv;
public TransparentProgressDialog(Context context, int resourceIdOfImage) {
super(context, R.style.TransparentProgressDialog);
WindowManager.LayoutParams wlmp = getWindow().getAttributes();
wlmp.gravity = Gravity.CENTER_HORIZONTAL;
getWindow().setAttributes(wlmp);
setTitle(null);
setCancelable(false);
setOnCancelListener(null);
resourceIdOfImage = R.drawable.loading_spinner_icon;
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(resourceIdOfImage);
layout.addView(iv, params);
addContentView(layout, params);
}
@Override
public void show() {
super.show();
//DEFINE ANIMATION WHICH YOU WANT
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(700);
iv.setAnimation(anim);
iv.startAnimation(anim);
}
}
USAGE:
TransparentProgressDialog pd=new TransparentProgressDialog(con, R.drawable.loading_spinner_icon);
pd.show();
pd.dismiss();
USE OBJECT OF THIS CLASS AS A PROGRESS DIALOG AND PASS CONTEXT AND ID OF DRAW ABLE WHICH YOU WANT TO SHOW AS PROGRESS DIALOG IN CONSTRUCTOR.
public class TransparentProgressDialog extends Dialog {
private ImageView iv;
public TransparentProgressDialog(Context context, int resourceIdOfImage) {
super(context, R.style.TransparentProgressDialog);
WindowManager.LayoutParams wlmp = getWindow().getAttributes();
wlmp.gravity = Gravity.CENTER_HORIZONTAL;
getWindow().setAttributes(wlmp);
setTitle(null);
setCancelable(false);
setOnCancelListener(null);
resourceIdOfImage = R.drawable.loading_spinner_icon;
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(resourceIdOfImage);
layout.addView(iv, params);
addContentView(layout, params);
}
@Override
public void show() {
super.show();
//DEFINE ANIMATION WHICH YOU WANT
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(700);
iv.setAnimation(anim);
iv.startAnimation(anim);
}
}
USAGE:
TransparentProgressDialog pd=new TransparentProgressDialog(con, R.drawable.loading_spinner_icon);
pd.show();
pd.dismiss();
USE OBJECT OF THIS CLASS AS A PROGRESS DIALOG AND PASS CONTEXT AND ID OF DRAW ABLE WHICH YOU WANT TO SHOW AS PROGRESS DIALOG IN CONSTRUCTOR.
0 comments:
Post a Comment