Android Collapsible banner ads AdMob
How to add the Collapsible banner ad into Android app.
- Go to admob and create a new Ad ba
2. Add the below kotlin function
private fun loadBanner() {adView = AdView(this);
adView.adUnitId = "ca-app-pub-3940256099942544/2014213617"
adView.setAdSize(adSize)
// Create an extra parameter that aligns the bottom of the expanded ad to
// the bottom of the bannerView.
val extras = Bundle()
extras.putString("collapsible", "bottom")
val adRequest = AdRequest.Builder()
.addNetworkExtrasBundle(AdMobAdapter::class.java, extras)
.build()
adView.loadAd(adRequest)
}
It’s the same config as the AdBanner, we just need to pass the parameter: extras
val extras = Bundle()
extras.putString("collapsible", "bottom")
[todo] Add image showing collapsible ad banner
Thank you for reading. Hope you learn something new.🙌🙏✌.
Don’t forget to clap 👏 50 times to support me and follow me for more such useful articles about Android Development, Gemini AI, Kotlin & KMP.
If you need any help related to Android, Kotlin and KMP. I’m always happy to help you.
[Hopefully you will find this useful]
Thank you for reading!
- If you enjoyed this, please follow me on Medium
- Buy me a coffee
Follow me on:
Thank you for taking the time to read this. I welcome your feedback on how I can improve or if you have any questions.
— Andres 🙌🏻
References:
https://developers.google. com/ ad- manager/ mobile- ads- sdk/ android/ banner/ collapsible