Progress dialog error in Android 4.4.4
I am using progress dialog in my android app. It looks great on Android 5.0+. But below in Androidroid 4.4.4, it shows two layers. I have connected a screenshot. I am using style
<style name="AlertDialogCustom" parent="Theme.AppCompat.Dialog">
<item name="colorAccent">#FFFFFF</item>
<item name="android:textColorPrimary">#CCCCCC</item>
<item name="android:background">#E43F3F</item>
</style>
and execution dialog
final ProgressDialog progressDialog = new ProgressDialog(SplashActivity.this,
R.style.AlertDialogCustom);
progressDialog.setIndeterminate(true);
progressDialog.setMessage("Authenticating...");
progressDialog.show();
How to fix this problem. Please suggest me.
source to share
Maybe you can add these to your style:
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
This works well for my situation.
source to share
I had the same situation (tested in API 16) changing the import to
import android.support.v7.app.AlertDialog;
or adding
<item android:windowBackground="@android:color/transparent" />
the style didn't work for me.
I created a folder values-v21
with a default material style and added
<item name="android:background">@android:color/transparent</item>
<item name="android:windowBackground">@android:color/transparent</item>
to a file style.xml
in a folder values
.
source to share
You need to create custom styling for your ProgressDialog on Android <= API 20.
<style name="AppTheme.AlertDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.ProgressDialog" parent="AppTheme.AlertDialog">
<item name="android:windowBackground">@android:color/transparent</item>
</style>
Then you need to style the ProgressDialog for it to work:
if (Build.VERSION.SDK_INT < 21)
{
mProgress = new ProgressDialog(mActivity, R.style.AppTheme_ProgressDialog);
}
else
{
mProgress = new ProgressDialog(mActivity);
}
....
Hope this helps.
source to share
I fixed it with external library https://github.com/afollestad/material-dialogs Simple and nice.
new MaterialDialog.Builder(this)
.title(R.string.progress_dialog)
.content(R.string.please_wait)
.progress(true, 0)
.progressIndeterminateStyle(true)
.show();
source to share