I have an activity with FragmentDialog. In onResume of this dialog I set height and weight of it to 80% and 90% by code:
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.copyFrom(getDialog().getWindow().getAttributes());
layoutParams.width = (int)(screenWidth * 0.9);
layoutParams.height = (int)(screenHeight * 0.8);
getDialog().getWindow().setAttributes(layoutParams);
It works perfectly, background has shadow, foreground FragmentDialog has proper dimensions. Question is - how can I show SnackBar at the bottom of the screen not affected by FragmentDialog (one that has shadow, Activity view) without shadow? Is there any way to disable shadow for specific view at activity that is in background of FragmentDialog?
Material design documentation says "Snackbars appear above most elements on screen, and they are equal in elevation to the floating action button. However, they are lower in elevation than dialogs, bottom sheets, and navigation drawers". From there, I think you should consider displaying the Snackbar inside the DialogFragment or just display a small dialog on top of it.
If you want to display Snackbar inside dialog fragment, you could do something like this:
public void showSnackBar(final View parent, final String text) {
Snackbar sb = Snackbar.make(parent, text, Snackbar.LENGTH_LONG);
sb.show();
}
parent is the entire dialog's view. You could improve it by making the root view of the fragment a CoordinatorLayout and showing the Snackbar on that view.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With