How to remove transparent dark background outside of dialog box

Madhav Bhattarai picture Madhav Bhattarai · Jan 31, 2014 · Viewed 17.2k times · Source

I want to remove a transparent dark backgrond outside of dialog box.

enter image description here

I tried with:

final Dialog dialog = new Dialog(this);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.WHITE));
        this.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.WHITE));
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.spinner_layout);
         getWindow().getDecorView().setBackgroundResource(android.R.color.transparent);

Answer

bsentuna picture bsentuna · Oct 5, 2015

In addition to chuky's answer;

If your minSdkVersion value is greater than or equal to 14, you can use setDimAmount() method.

dialog.getWindow().setDimAmount(float amount);

According to reference;

amount The new dim amount, from 0 for no dim to 1 for full dim.

or

As stated previously, you can clear window flag.