amit
amit

Reputation: 1413

How to completely black out background on Android dialog?

I am showing an Activity with dialog theme (android:theme="@android:style/Theme.Dialog")

When I pop up this activity, I want to completely blacken out the background activity. Currently, the activity underneath has too much clutter, and even though it is blurred, it is still too visible.

Thanks.

Upvotes: 2

Views: 1543

Answers (2)

dan shirron
dan shirron

Reputation: 19

Try this:

WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();  
lp.dimAmount=1.0f;
dialog.getWindow().setAttributes(lp);  
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

Upvotes: 2

user948620
user948620

Reputation:

make a file style.xml and put this xml code

<style name="blackDialog" parent="android:style/Theme.Dialog" >
        <item name="android:background">@null</item>    
</style>

In your manifest file add android:theme="@style/AppTheme" attribute in your activity

<activity android:theme="@style/blackDialog" 
      android:name=".Activity2" 
      android:label="@string/title" />

Upvotes: 1

Related Questions