title: An AdView element creates a blank area on some devices?
body: <p>I have an AdView element in a relatively simple layout, which is shown/hidden depending whether the user has enabled ads, and whether any ads are available.</p>
  
  <p>The RelativeLayout that contains the AdView is hidden by default, and is only shown to the user when <code>onAdLoaded()</code> is called. If the user has disabled ads, or if <code>onAdFailedToLoad()</code> is called, then the RelativeLayout remainds hidden (or is re-hidden if it was shown for some reason previously).</p>
  
  <p>This is working fine on most devices, but for a small number of devices (including a Samsung Galaxy Ace) there is a problem. With ads turned off everything is fine, but if ads are turned on then the AdView takes up the appropriate amount of space, but is completely blank (it's not black, it's just completely invisible).</p>
  
  <p>This is the relevant segment of the layout file:</p>
  
  <pre><code>&lt;RelativeLayout
          android:id="@+id/adContainer"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:visibility="gone"
          style="@style/layout_row"&gt;
  
      &lt;!-- AdView is inserted here --&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><code>@style/layout_row</code> just adds a little margin along the top to keep it off the very top of the screen, but nothing else.</p>
  
  <p>This is the section of the code that creates and inserts the ad (called inside <code>onResume()</code>):</p>
  
  <pre><code>// hide advert by default
  findViewById(R.id.adContainer).setVisibility(View.GONE);
  
  // check if ads are turned on
  if (prefs.getBoolean("show_ads", true)) {
      // create a new ad view
      AdView adView = new AdView(this);
      adView.setAdSize(AdSize.BANNER);
      adView.setAdUnitId("___ MY ID ___");
  
      // add it to the relative layout
      ((RelativeLayout) findViewById(R.id.adContainer)).addView(adView);
  
      // deal with the arrival of ads
      adView.setAdListener(new AdListener() {
  
          // hide ad block if none could be found
          @Override
          public void onAdFailedToLoad(int errorCode) {
              findViewById(R.id.adContainer).setVisibility(View.GONE);
              super.onAdFailedToLoad(errorCode);
          }
  
          // show ad block if one was found
          @Override
          public void onAdLoaded() {
              findViewById(R.id.adContainer).setVisibility(View.VISIBLE);
              super.onAdLoaded();
          }
  
      });
  
      // request ads
      AdRequest adRequest = new AdRequest.Builder()
              .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // Emulators
              .addTestDevice("8AFD3F7DD723DA9355EE3B35E8666475") // My Samsung S4 test device
              .build();
      adView.loadAd(adRequest);
  } else {
      // hide the ad block
      findViewById(R.id.adContainer).setVisibility(View.GONE);
  }
  </code></pre>
  
  <p>To repeat, <strong>this works absolutely fine on most devices</strong>, including devices that set the ads to test mode and those that don't. The problem has only appeared so far on a Galaxy Ace, but unfortunately I don't have access to the device to read the logcat.</p>
  
  <p>Can anyone offer me any advice about what might be causing this and what could be done to fix it?</p>
  
  <p>Thanks :)</p>
  
  <p><strong>UPDATE:</strong> I put a bright pink background colour on the <code>RelativeLayout</code> to see what was going on, and I found that on the problematic device, the layout <em>was</em> being shown - there's a big pink block in the size and shape of the ad, right where the ad should be. This can only mean that <code>onAdLoaded()</code> is being called, but still no ad is being show. Any ideas?</p>