Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom screen dim with Dialog

Tags:

android

dialog

In Android when you pop up a dialog the screen behind it dims. Is there any way to control what that looks like? For example making it dim more or less or using some kind of a pattern?

like image 972
CaseyB Avatar asked Jun 06 '11 19:06

CaseyB


People also ask

What is DialogFragment?

Android DialogFragments. DialogFragment is a utility class which extends the Fragment class. It is a part of the v4 support library and is used to display an overlay modal window within an activity that floats on top of the rest of the content. Essentially a DialogFragment displays a Dialog but inside a Fragment.

How to show custom dialog Fragment?

Showing the DialogFragment It is not necessary to manually create a FragmentTransaction to display your DialogFragment . Instead, use the show() method to display your dialog. You can pass a reference to a FragmentManager and a String to use as a FragmentTransaction tag.

How to use DialogFragment in android?

Extend this class with the DialogFragment method. Make an OnCreateView and Inside that use, inflater to inflate the UI of Dialog Box which is already created. Here is the all code for DialogFragment. java, you can paste it just after your package name.

How do I change the background color of alert in dialog?

To change the background color of all dialogs and pop-ups in your app, use colorBackgroundFloating attribute. Save this answer. Show activity on this post. I was looking at the material.io/components/dialogs/android#full-screen-dialog where the container color element has no attribute.


1 Answers

Yes, it is. You can control it.

After creating dialog:

WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();   lp.dimAmount = 0.0f; // Dim level. 0.0 - no dim, 1.0 - completely opaque dialog.getWindow().setAttributes(lp); 

Upd: you can even add blur behind the dialog:

dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); 

Upd2: Blurring is deprecated since API14:

This constant was deprecated in API level 14.
Blurring is no longer supported.

like image 116
Sergey Glotov Avatar answered Oct 14 '22 17:10

Sergey Glotov