I have an android application which has many different pop-ups. I want to add a SnackBar
over dialog's overlay on the bottom of the screen.
I tried the following code
if (fragment!= null) {
Snackbar snackbar = Snackbar.make(fragment.getDialog().getWindow().findViewById(android.R.id.content),
message, Snackbar.LENGTH_LONG);
View view = snackbar.getView();
FrameLayout.LayoutParams params =(FrameLayout.LayoutParams)view.getLayoutParams();
params.gravity = Gravity.BOTTOM;
view.setLayoutParams(params);
snackbar.show();
}
But the SnackBar
appears on the bottom of centered Dialog
not on the bottom of the screen. If I add the Snackbar
on current Activity
then it appears under dialog's overlay.
Use below theme for full screen custom dialog
<style name="DialogTheme" parent="android:Theme.Dialog">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<!-- No backgrounds, titles or window float -->
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
Use it in your dialog as below:
dialog = new Dialog(this, R.style.DialogTheme);
To use above things, you should use custom layout for your custom dialog.
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Try above line to make your dialog background transparent.