1

We have an infuriating situation with what are called "fluid ads" on Android in a React Native app. Basically the React Native layout infrastructure and the Google Ads Android infrastructure do not play nice. We have hacked it up enough such that we know the intended size of the ad, but it refuses to become that says. The view hierarchy is as follows:

Our RN View (DFPBannerViewGroup) .POBBannerView (Pubmatic) ..AdManagerAdView (Google) ...FrameLayout (internal to google stuff) ....ViewGroup (some obfuscated google class) .....WebView (fluid really just means HTML I guess)

Our general solution is that after some small time we ask the WebView for its content height with getContentHeight, and then are TRYING to get all the views to respect that. Sometimes, it does not work. We call layout on the POBBannerView like so:

adView.measure(adPixelWidth, adPixelHeight);
adView.layout(0, 0, adPixelWidth, adPixelHeight);

I have verified with logging statements that, when it goes wrong, the POBBannerView, AdManagerAdView and FrameLayout all have the correct heights (usually 150 for the test ad I'm using). But the obfuscated ViewGroup and WebView do not. They get stuck at 39. I've tried calling requestLayout on them, setting their height explicitly, and a number of other things, but they do not want to fill their parents, even though I'm pretty sure that's how their layouts are setup. It works in non-React Native apps, so this surely has something to do with Dr. Frankenstein, but I can't figure out what. Here's what I have now:

adView.measure(adPixelWidth, adPixelHeight);
adView.layout(0, 0, adPixelWidth, adPixelHeight);
getWebView(adView).requestLayout();

I've also tried delaying that requestLayout by some time, but same behavior. Any idea what the heck is going on here?

Thanks!

Max Metral
  • 261
  • 3
  • 12

0 Answers0