Android: how to get rid of the strange border around the dialogue of progress

I created my own style for the dialogue of progress, however it has strange borders around it.

dialogue of progress

Here is the topic:

<style name="AppTheme.Dialog" parent="Theme.AppCompat.Light.Dialog"> <item name="colorAccent">@android:color/white</item> <item name="android:textColorPrimary">@android:color/white</item> <item name="android:background">@color/colorPrimaryDark</item> <item name="android:popupBackground">@null</item> </style> 

Any ideas why there is such a weird background?

+8
android android-layout progressdialog
source share
5 answers

To remove a colored or white border around the run dialog box, the dialog uses a theme that defines a transparent windowBackground

 <style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog"> <item name="android:windowBackground">@android:color/transparent</item> </style> 

When creating a dialog, use this topic:

 new ProgressDialog(MyActivity.this, R.style.MyDialogTheme); 
+6
source share

he is related to this issue . But unlike the warning dialog, there is no AppCompat support for the ProgressDialog. I could not solve the problem, it could be used modified THEME_HOLO_LIGHT

 ProgressDialog dialog= new ProgressDialog(this,ProgressDialog.THEME_HOLO_LIGHT); 

but you will lose all the advantages of AppCompat (for example, color accent).

+1
source share

Please add:

 your_progress_dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); 

into your java.

Hope this helps!

0
source share

Create two styles

1) API level less than 19

  <style name="AppAlertTheme19" parent="Theme.AppCompat.Light.Dialog"> <item name="colorAccent">@color/btngreen</item> <item name="android:textColorPrimary">@color/transparent</item> <item name="android:background">@color/transparent</item> <item name="android:windowBackground">@color/transparent</item> <item name="android:popupBackground">@null</item> </style> 

2) API level above 19

 <style name="AppAlertTheme" parent="Theme.AppCompat.Light.Dialog"> <item name="colorAccent">@color/btngreen</item> <item name="android:textColorPrimary">@color/transparent</item> <item name="android:background">@color/white</item> <item name="android:windowBackground">@color/transparent</item> <item name="android:popupBackground">@null</item> </style> 

3) and view a progress view like this

 public class ProgressDialogCustom extends ProgressDialog { public ProgressDialogCustom(Context context) { super(context, getStyle()); setMessage("Please Wait ..."); setCancelable(false); } private static int getStyle() { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { return R.style.AppAlertTheme; } else { return R.style.AppAlertTheme19; } } } 
0
source share

I may be late to answer this question, but since I ran into the same problem, I solved it as follows:
I created 2 styles, one for the higher candy and one for the lower.

API Level Above 19

 <style name="AppAlertTheme" parent="Theme.AppCompat.Light.Dialog"> <item name="colorAccent">@color/white</item> <item name="android:textColorPrimary">@color/transparent</item> <item name="android:background">@color/blue</item> <item name="android:windowBackground">@color/transparent</item> <item name="android:popupBackground">@null</item> </style> 

API level less than 19

 <style name="AppAlertTheme_api19" parent="android:Theme.Holo.Dialog"> <item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item> <item name="android:windowBackground">@color/nlue</item> <item name="android:background">@android:color/transparent</item> <item name="android:backgroundDimEnabled">false</item> <item name="android:textColor">@color/white</item> </style> <style name="CustomAlertDialogStyle"> <item name="android:bottomBright">@android:color/transparent</item> <item name="android:bottomDark">@android:color/transparent</item> <item name="android:bottomMedium">@android:color/transparent</item> <item name="android:centerBright">@android:color/transparent</item> <item name="android:centerDark">@android:color/transparent</item> <item name="android:centerMedium">@android:color/transparent</item> <item name="android:fullBright">@android:color/transparent</item> <item name="android:fullDark">@android:color/transparent</item> <item name="android:topBright">@android:color/transparent</item> <item name="android:topDark">@android:color/transparent</item> </style> 

Then this style was used as follows:

 public int getProgressDailogStyle(){ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { return R.style.AppAlertTheme; } else { return R.style.AppAlertTheme_api19; } } 

and finally

  progressDialog = new ProgressDialog(context, getProgressDailogStyle()); 

Hope this helps you.

0
source share

All Articles