title: Adapting AdMob banner size to screen size
body: <p>I'm really struggling to find a solution to adapt the size of the banner to the device. I have a Samsung tablet 8" and a htc phone.</p>
  
  <p>There is one app (radio) that is exactly doing what I need.</p>
  
  <p>Tablet:</p>
  
  <p><a href="https://i.stack.imgur.com/ISbBP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ISbBP.png" alt="enter image description here"></a></p>
  
  <p>Phone:</p>
  
  <p><a href="https://i.stack.imgur.com/7Ok9t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Ok9t.png" alt="enter image description here"></a></p>
  
  <p>The width on the tablet is almost twice the one on the phone. Same with the font.</p>
  
  <p>I read <a href="https://firebase.google.com/docs/admob/android/banner" rel="nofollow noreferrer">https://firebase.google.com/docs/admob/android/banner</a> but I can't find the right solution.</p>
  
  <p>I tried:</p>
  
  <pre><code>    AdView mAdView;
      mAdView = (AdView) getActivity().findViewById(R.id.bac_adView);
      mAdView.setVisibility(View.VISIBLE);
      mAdView.setAdSize(AdSize.SMART_BANNER);
      AdRequest adRequest = new AdRequest.Builder()
              .addTestDevice("xxxxxxxxxxxxxxxxxxxxxxxxxx")
              .build();
      mAdView.loadAd(adRequest);
  </code></pre>
  
  <p>and I get the error: java.lang.IllegalStateException: The ad size can only be set once on AdView.</p>
  
  <p>But I'm not even sure this is the right way of doing.</p>
  
  <p>Any pointers to some code would be great!</p>