Using custom ProgressDialog android

This answer does not address the problem stated in the question, but when searching for how to implement a custom progress dialog, this is the only link pointing to SO. That said, I found a cool and easy-to -use custom progress dialog by a certain Maksym Dybarskyi on this link.

All Credit goes to the creator, not me.Am just sharing

All you need to do is add this to your dependencies:

dependencies {
...
   compile 'com.github.d-max:spots-dialog:0.4@aar'
}

And then the custom style:

<style name="Custom" parent="android:Theme.DeviceDefault.Dialog">
    <item name="DialogTitleAppearance">@android:style/TextAppearance.Medium</item>
    <item name="DialogTitleText">Please Wait</item>
    <item name="DialogSpotColor">@android:color/holo_orange_dark</item>
    <item name="DialogSpotCount">8</item>
</style>

Finally, in your code do this:

private AlertDialog progressDialog;
progressDialog = new SpotsDialog(mContext, R.style.Custom);

//Am using it in an AsyncTask. So in  my onPreExecute, I do this:
public void onPreExecute() {
  super.onPreExecute();
  progressDialog.show();
  ...
 }

//dismiss in onPostExecute
public void onPostExecute(){
   progressDialog.dismiss();
 } 

Result:

enter image description here

The yellow dots move from left to right and you can change the number of dots in styles


Just check for using activity name in your constructor of progress dialog,

 progressDialog = new ProgressDialog(Activity.this,R.style.CustomDialog);

I'm using custom ProgressDialog in my application . For that we have to follow some steps this are as follow.

step-1 Create a xml layout custom_progress.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:padding="@dimen/dp_size_10"
    android:layout_height="match_parent">
<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:indeterminateTint="@color/colorPrimary"
    android:layout_centerInParent="true"/>
</RelativeLayout>

step-2 Create a java file for this custom dialog.

package com.example.customeprogress;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;

public class CustomProgressDialogue extends Dialog {
    public CustomProgressDialogue(Context context) {
        super(context);

        WindowManager.LayoutParams wlmp = getWindow().getAttributes();

        wlmp.gravity = Gravity.CENTER_HORIZONTAL;
        getWindow().setAttributes(wlmp);
        setTitle(null);
        setCancelable(false);
        setOnCancelListener(null);
        View view = LayoutInflater.from(context).inflate(
                R.layout.custom_progress, null);
        setContentView(view);
    }
}

step-3 Create a object of this custom class in your activity java class and initialised it as follow use the object for show() or dismiss()

CustomProgressDialogue object=new CustomProgressDialogue(this);

and show this dialog using.

object.show(); and dismissed it using object.dismiss();

Result of output. see out put here


I know I'm quite late to answer but I'll answer any way,

Dialog dialog = new  Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_login);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));