15
Finally, to add an AdMob advertisement to your application, open your desired layout xml file.
For this tutorial we will just add it to our main.xml located under
res/layout folder of our project. Then add this following xml where you
like to show your ad in your layout.
- In <LinearLayout> tag add xmlns:ads= "http://schemas.android.com/apk/lib/com.google.ads" After the <LinearLayout> tag add <com.google.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="YOUR PUBLISHER ID" ads:loadAdOnCreate="true" > </com.google.ads.AdView>
