Dialog dialog = new Dialog(FlashActivity.this, android.R.style.Theme_Dialog); dialog.setCancelable(false); ImageView imageView = new ImageView(this); imageView.setScaleType(ScaleType.FIT_XY); imageView.setBackgroundResource(R.drawable.progress_dialog_icon_drawable_animation); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(imageView); dialog.setCanceledOnTouchOutside(false); dialog.getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.color_drawable_1)); dialog.show(); AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground(); animationDrawable.start();
Below is color_drawable_1
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@color/transparent"></item> </selector>
Below is transparent in colors.xml (you can put any transparent color here)
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="transparent">#00ffffff</color> </resources>
Below is your progress_dialog_icon_drawable_animation
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/icon_progress_dialog_drawable_1" android:duration="150" /> <item android:drawable="@drawable/icon_progress_dialog_drawable_2" android:duration="150" /> <item android:drawable="@drawable/icon_progress_dialog_drawable_3" android:duration="150" /> <item android:drawable="@drawable/icon_progress_dialog_drawable_4" android:duration="150" /> <item android:drawable="@drawable/icon_progress_dialog_drawable_5" android:duration="150" /> <item android:drawable="@drawable/icon_progress_dialog_drawable_6" android:duration="150" /> <item android:drawable="@drawable/icon_progress_dialog_drawable_7" android:duration="150" /> <item android:drawable="@drawable/icon_progress_dialog_drawable_8" android:duration="150" /> <item android:drawable="@drawable/icon_progress_dialog_drawable_9" android:duration="150" /> </animation-list>
Since you are creating a custom dialog, do not create the dialog as an instance of progressdialog. Create an instance of the dialog box. Add an image to your view. Adjust the image with the ability to draw and start the animation. Now you need to change the windows dialog as you need. Do it like no headline, because the dialogue topic usually has a headline, and you must set its background color with any transparent color.
Try the above and you can tell me about any problems. He works.
Satish Nov 08 '14 at 19:22 2014-11-08 19:22
source share