Dialog Progress has a white background on Lollipop devices,

I am transferring my application to Android 5.0, that is, to Lollipop devices, I have a problem with the progress dialog. It works great on devices with a preliminary lollipop, but on a lollipop it has a white background, as shown in the figure. enter image description here

But on devices with pre-candy it's a 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 use 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); 
+6
source share
4 answers

I solved this problem with this tutorial http://www.techrepublic.com/blog/software-engineer/create-a-transparent-progress-dialog-on-android/

I just pass my code to this code

 mProgressDialog = new TransparentProgressDialog(context, **R.drawable.progress**); mProgressDialog.setCancelable(false); 

and the break code is the same as in this example.

+1
source

The problem was on a white background on a lollipop.

one of two (both are the same):

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

or

 dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); 
+4
source

It looks like you have a solution now, but if someone else is experiencing a similar problem; I found that overriding the ProgressDialog theme in the constructor worked for me. Sort of:

 mProgressDialog = new ProgressDialog(context, ProgressDialog.THEME_HOLO_LIGHT); 
+2
source

You can also create a style and assign a style in the dialog box:

  ProgressDialog dialog = new ProgressDialog(context, R.style.ProgressDialogStyle); 

Style (in .xml style):

 <style name="ProgressDialogStyle" parent="android:Theme.Holo.Light.Dialog"> <item name="android:windowBackground">@color/color_transparent</item> </style> 
+2
source

Source: https://habr.com/ru/post/987476/


All Articles