2

I am making a custom progress bar using one small image/icon which will basically rotate. But in the background there is white patch or background is showing. I have attached the image here..

I have used the below code for this:

CustomDialog.java

 public class CustomDialog extends Dialog{

    public Activity c;
     public CustomDialog(Activity a) {
            super(a);
            // TODO Auto-generated constructor stub
            this.c = a;
          }

     public CustomDialog(Activity a, int s) {
            super(a, s);
            // TODO Auto-generated constructor stub
            this.c = a;
          }

     @Override
      protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.progressbar);
        setCancelable(true);
      }

}

progressbar.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/transparent"
    android:gravity="center"
    android:orientation="vertical" >

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:indeterminate="true"
        android:background="@android:color/transparent"
        android:indeterminateDrawable="@drawable/my_progress_interminate" >
    </ProgressBar>

</RelativeLayout>

my_progress_interminate.xml

<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/sai_icon" 
    android:pivotX="50%"
    android:pivotY="50%" />

How can i remove the white background here.. Please help. image

Arindam Mukherjee
  • 2,155
  • 10
  • 46
  • 78

3 Answers3

3

This is working for me. Add this to the onCreate of your dialog.

getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Bojan Kseneman
  • 14,663
  • 2
  • 50
  • 58
1

The simplest way, add this line to your progress bar XML:

android:background="@android:color/transparent"
Marco
  • 597
  • 2
  • 9
  • 29
1

Just Do The Below Method To Get It Done

In res->values->styles add the below code

<style name="MyGravity" parent="android:Theme.Material.Dialog" ></style>

Then create yours ProgressDialog as mentioned below

ProgressDialog dialog = new ProgressDialog(ctx, R.style.MyGravity);
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
dialog.setTitle("Your Title");
dialog.setMessage("Your Message");
Arun Mohan
  • 201
  • 2
  • 11