Hello there I'm using a dialog and I want to blur the background but there is an issue
I'm trying to achieve blur similar to this
I find a question that has the same issue but unsolved Alert dialog blur only part of the screen
ok I have used this answer and it worked perfectly but the blur is only showing around the dialog and not for the entire layout
this is the line of code I have implemented from the answer, entier code is below the image
getDialog().getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
here is the screenshot of what I'm getting
as you can see the blur is working perfectly but it's not proper
Here is the code
Note:- I only include the necessary files and the code so the question doesn't get long and confusing but if you want more references of the code please tell me I will update the question
dialog.java
public class sort_image_dialoge_fragment extends DialogFragment {
@Nullable
@org.jetbrains.annotations.Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.sort_image, container, false);
if (getDialog() != null && getDialog().getWindow() != null) {
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
// This is the line i have implemented form the answer to blur the background
getDialog().getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
}
return view;
}
}
Home_Fragment.java // this is the layout that has to be blurred and contains the text view when pressed brings up the dialog
TextView sortDialoge_textView;
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
sortDialoge_textView = view.findViewById(R.id.sort_text);
sortDialoge_textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sort_image_dialoge_fragment sortDialoge = new sort_image_dialoge_fragment();
sortDialoge.show(requireActivity().getSupportFragmentManager(), sortDialoge.getTag());
}
});
return view;
}