Search code examples
androidadmobandroid-snackbar

Snackbar overlays Admob banner ad


I have a snackbar which overlays the banner ad. It has a LENGTH_INDEFINITE because I have some functionality I need to complete after the snackbar is displayed.

Would this be considered a violation of the admob's banner policy described here - https://support.google.com/admob/answer/6275345?hl=en

What I have tried to overcome this ?

I have created a constraintlayout as a parent with it's children being the banner ad and another constraintlayout with everything you see in the layout. I am rendering the snackbar on the child layout, yet it renders out of it's layout on to the parents bottom.

enter image description here


Solution

  • Anchor your Snackbar on the AdView, then it will be always displayed above the AdView.

    Call below on your SnackBar before displaying it to the user.

    setAnchorView(findViewById<AdView>(R.id.your_adview_id))
    

    More details here: SnackBar Android