Question

I'm implementing ads in my android app. They work fine, but it takes them a few seconds to pop up which then resizes my layout elements. I want to have the layout elements pre-resized even before the ad is loaded so they don't shift once it is.

Is there any way to replace an existing view (taking up the space where the ad would go) with the ad view once it's loaded? Any other way to get the same effect?

Thanks

(Also, I'm adding the ad view programmatically, not through XML, though I could change that if need be)

Was it helpful?

Solution 2

What I ended up doing is setting the adView's minimum height equal to 50 pixels multiplied times the density factor (1.5 for high, 1 for medium, .75 for low) since those values correspond to the ad height for banners. Works perfectly.

OTHER TIPS

Assuming you're using AdSize.BANNER, the AdView has 50dp height. You can incorporate the AdView in XML and give it 50dp height, or your can define a container layout in XML with 50dp height and add the AdView programmatically to the container layout.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top