Disable background dim on ProgressDialog/AlertDialog in Android
Asked Answered
D

3

31

I use an AsyncTask with a ProgressDialog in it. This automatically causes a background dim of about 40%. I want to turn this dim off (0% dim), but what I tried, didn't work:

myLoadingDialog = new ProgressDialog(MainActivity.this.getApplicationContext());
myLoadingDialog.setMessage("Loading...");
myLoadingDialog.setIndeterminate(true);
myLoadingDialog.setCancelable(false);
WindowManager.LayoutParams lp = myLoadingDialog.getWindow().getAttributes();
lp.dimAmount = 0.0f; 
myLoadingDialog.show();

The problem with that dim was, that I had to terminate my Tablet's SystemUI-Process to achieve a Kiosk mode (with no System-Bar) and the ProgressDialog dims everything but the area where the System-Bar was, so I have a bright border at the bottom of the screen.

If there is a way to get a complete fullscreen-dim, I would be also happy.

Thanks for any help

Dirtcheap answered 17/10, 2012 at 16:26 Comment(0)
I
100

use

myLoadingDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHI‌​ND);
Ilianailine answered 17/10, 2012 at 16:36 Comment(0)
K
3

you can add this theme to solve this problem also

<item name="android:backgroundDimEnabled">false</item>
Krispin answered 18/12, 2019 at 9:45 Comment(0)
T
0

You can also change the relative amount of dimming with the following:

window?.setDimAmount(0.2f)

This is set in onCreate of your dialog class.

Tegucigalpa answered 13/9, 2021 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.