Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DialogFragment with clear background (not dimmed)

I'm trying to get the background of a DialogFragment to be completely clear.

With setting the style item android:windowIsFloating to true (the default), the DialogFragment displays exactly how I want it to, but has a very dimmed background.

By setting android:windowIsFloating to false, I get the clear background I want, but the DialogFragment blows up to about 95% of the screen, leaving only a tiny gap around it where you can see through to the view it overlays.

I've tried ton's of tweaks and cannot seem to override this behavior.

Do I need to use a PopupWindow to achieve the desired effects, or are there some style items that I can override ?

like image 476
samus Avatar asked Dec 11 '12 15:12

samus


People also ask

How do you finish DialogFragment?

Show activity on this post. tl;dr: The correct way to close a DialogFragment is to use dismiss() directly on the DialogFragment. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog.

How do you pass arguments to DialogFragment?

you can set your args. class IntervModifFragment : DialogFragment(), ModContract. View { companion object { fun newInstance( plom:String,type:String,position: Int):IntervModifFragment { val fragment =IntervModifFragment() val args = Bundle() args. putString( "1",plom) args.

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 is DialogFragment implemented?

To create a DialogFragment , first create a class that extends DialogFragment , and override onCreateDialog() , as shown in the following example. Similar to how onCreateView() should create a root View in an ordinary fragment, onCreateDialog() should create a Dialog to display as part of the DialogFragment .


1 Answers

What works for me is to adjust the WinowManager.LayoutParams in onStart() of the DialogFragment:

@Override public void onStart() {     super.onStart();      Window window = getDialog().getWindow();     WindowManager.LayoutParams windowParams = window.getAttributes();     windowParams.dimAmount = 0.90f;     windowParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;     window.setAttributes(windowParams); } 
like image 51
Christopher Perry Avatar answered Oct 13 '22 10:10

Christopher Perry