I recently moved my project from the AdMob SDK to Google ads, but Iβm having a slight problem with Google ads.
I have the look of an advertising banner in action, and I would dynamically customize the buttons in the layout depending on whether the ad was loaded. It worked great when I used the AdMob SDK, but now with Google ads, the banner is always reserved there with a space before loading the ad. And if the ad cannot be loaded (say, without a network), an empty view is displayed here, which is pretty ugly! That is why I would like to dynamically adjust the layout ...
Did I miss something while changing the code? Thank you for your help!
Here is a snippet of java code and layout file:
Java:
import com.google.android.gms.ads.*; ... public class MyActivity extends Activity { ... @Override public void onCreate(Bundle savedInstanceState) { ... AdView adView = (AdView)findViewById(R.id.ad); AdRequest adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest); } }
XML format:
... <com.google.android.gms.ads.AdView android:id="@+id/ad" android:layout_alignParentBottom="true" android:layout_width="match_parent" android:layout_height="wrap_content" ads:adUnitId="AD_PUB_ID" ads:adSize="BANNER"/> </RelativeLayout>
source share