Changing Background dim color for dialog appears in android

android, android-theme, dialog

Solution

It is a very old question, but i'd like to add n answer to it. I faced the same problem and googled a lot. Then came up with my own solution.

First of all, I removed the dim at all with this

dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

And then I opened my layout(it was RelativeLayout) and put this view in it as the last element

<View
        android:id="@+id/shade"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/primaryShadow"
        android:visibility="invisible"/>

The background color is the color you want to use as your dim color. As you can see, it is invisible when created. So you'll need to find it in you Activity and set it's visibility before you launch the dialog to `View.VISIBLE`. When you cancel dialog, set it to `View.INVISIBLE` again. And that's it.

Problem

Hi I have to chage the dim color of dialog in my theme to white, so that by setting layoutParams.dimAmount = 0.5f; i can get blur white in dialog background. I am using ``` <style name="MyDialog" parent="@android:style/Theme.Holo.Light.Dialog"> <item name="android:windowBackground">@color/dialog_dim_background</item> </style> ``` and following below references How do I create a transparent Activity on Android? Custom screen dim with Dialog

Original source

Related problems