I am (still) looking for a way to pre-determine an estimated height for admob banners. I know Corona uses admob smart banners in the admob v2 plugin so I went ahead and found this information :
https://developers.google.com/admob/android/banner#smart_banners
I came up with a line of code that returns the appropriate result based on the information in the link above :
display.adMobHeight = display.pixelHeight \<= 400 and 32 or display.pixelHeight \> 400 and display.pixelHeight \<= 720 and 50 or display.pixelHeight \> 720 and 90
This is all good… but the units ( 32 , 50 or 90 ) are in google’s density-independent pixel. So my question is how can I get this translated into pixels for use in Corona and vice-versa? My config.lua looks like this :
-------------------------------------------------------------------------- local aspectRatio = display.pixelHeight / display.pixelWidth -------------------------------------------------------------------------- application = {} -------------------------------------------------------------------------- application.content = { width = aspectRatio \> 1.5 and 800 or math.ceil( 1200 / aspectRatio ), height = aspectRatio \< 1.5 and 1200 or math.ceil( 800 \* aspectRatio ), scale = "letterBox", fps = 60, imageSuffix = { ["@2x"] = 1.3, } } --------------------------------------------------------------------------
NOTE :
I know the issue of pre-determining the height of an admob banners has been discussed else where and the recommended solution is to show the ad and use the height returned from the callback. I am doing this but for the initial load of my screen I want to have UI elements roughly in the right place so when the ad shows with it’s inevitable delay, the UI re-shuffle that I perform is not too noticeable on most devices.