It's late but there is a solution I think may be useful for others.
To disable the dialog fragment shadow (in fact it is called DIM), add below code to your dialog fragment onResume
method.
For Kotlin:
override fun onResume() {
super.onResume()
dialog?.window!!.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
}
For Java:
@Override
public void onResume() {
super.onResume();
if(getActivity()!=null)
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
}
by the this is not exactly what question is asking but this will omit all the shadow behind dialog fragment.
To show snackbar in you parent fragment rather than your dialog fragment, you can pass parent fragment reference to dialog fragment constructor and instantiate snackbar with parent's view. this will show the snackbar at the bottom of parent fragment.
showSnackbar
method would be like this:
For Kotlin:
private fun showSnackbar(messege: String) =
Snackbar.make(parent.view!!, messege, Snackbar.LENGTH_SHORT).show()
For Java:
private void showSnackBar(String messege) {
if (parent.getView() != null)
Snackbar.make(parent.getView(), messege, Snackbar.LENGTH_SHORT).show();
}
dialog fragment complete code would be like:
For kotlin:
class MyDialogFramgent(parent: Fragment) : DialogFragment() {
// class code ...
override fun onResume() {
super.onResume()
dialog?.window!!.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
}
private fun showSnackbar(messege: String) =
Snackbar.make(parent.view!!, messege, Snackbar.LENGTH_SHORT).show()
}
For Java:
public class MyDialogFragment extends DialogFragment {
private Fragment parent;
public MyDialogFragment(Fragment parent) {
this.parent = parent;
}
@Override
public void onResume() {
super.onResume();
if (getActivity() != null)
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
}
private void showSnackBar(String messege) {
if (parent.getView() != null)
Snackbar.make(parent.getView(), messege, Snackbar.LENGTH_SHORT).show();
}
}