Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Progress dialogue has white background on Lollipop Devices ,

I am migrating my application on Android 5.0 i.e. Lollipop devices , I have problem regarding progress dialog , It work perfectly on pre lollipop devices , but on lollipop it has white background as shown in image enter image description here

But in pre lollipop devices it is of transparent background enter image description here

Below is my code :

progress.xml in layout

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


<ProgressBar
        android:id="@+id/progressBar3"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
       android:background="@android:color/transparent"
        android:layout_centerHorizontal="true"

        android:indeterminate="true"
        android:indeterminateDrawable="@drawable/myprogress"
        android:minHeight="48dp" />
   </RelativeLayout>

myprogress.xml in drawable

<shape
    android:shape="oval"
    android:useLevel="false" >
    <size
        android:height="48dip"
        android:width="48dip" />

    <gradient
        android:centerColor="#ff001100"
        android:centerY="0.50"
        android:endColor="#ffffffff"
        android:startColor="#ff000000"
        android:type="sweep"
        android:useLevel="false" />
</shape>

and in Java i am using like this

public ProgressDialog mProgressDialog;

  if (mProgressDialog != null && mProgressDialog.isShowing()) {
            mProgressDialog.cancel();
        }

        mProgressDialog = new ProgressDialog(context);
        mProgressDialog.setCancelable(false);

        mProgressDialog.show();
        mProgressDialog.setContentView(R.layout.progress);
like image 216
EminenT Avatar asked May 19 '15 06:05

EminenT


People also ask

How to set progress bar in android?

In android there is a class called ProgressDialog that allows you to create progress bar. In order to do this, you need to instantiate an object of this class. Its syntax is. ProgressDialog progress = new ProgressDialog(this);

How to update progress bar android?

You can update the percentage of progress displayed by using the setProgress(int) method, or by calling incrementProgressBy(int) to increase the current progress completed by a specified amount. By default, the progress bar is full when the progress value reaches 100.

What is progress bar in android?

Android ProgressBar is a graphical view indicator that shows some progress. Android progress bar displays a bar representing the completing of the task. Progress bar in android is useful since it gives the user an idea of time to finish its task.


1 Answers

Issue was a white background on lollipop.

solution either of the two (both are same though):

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

or

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
like image 100
sud007 Avatar answered Oct 13 '22 22:10

sud007