android - Setup the bottom of the page AdMob banner -


i'm trying setup admob banner on bottom of page, ad not show. space appears bottom of page there, admob not show there.

  1. add , reference google play services library. - yes
  2. add meta-data tag in androidmanifest.xml. - yes
  3. declare com.google.android.gms.ads.adactivity in manifest. - yes
  4. set network permissions in manifest. - yes

somebody tell me why. thank you.

my xml

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <linearlayout         android:id="@+id/flcontainer"                <!-- data layout -->         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_above="@+id/ad_layout"         android:orientation="vertical" />      <linearlayout         android:id="@+id/ad_layout"                  <!-- admob layout -->         android:layout_width="match_parent"         android:layout_height="50dp"         android:layout_alignparentbottom="true"         android:orientation="vertical" />  </relativelayout> 

mainactivity.java

// create ad. adview = new adview(context); adview.setadsize(adsize.banner); adview.setadunitid(ad_unit_id);  // add adview view hierarchy. view // have no size // until ad loaded. linearlayout layout = (linearlayout) findviewbyid(r.id.ad_layout); //layout.getbottom(); layout.addview(adview);  // create ad request. check logcat output // hashed device id // test ads on physical device. adrequest adrequest = new adrequest.builder()         .addtestdevice(adrequest.device_id_emulator)         .addtestdevice("insert_your_hashed_device_id_here").build();  // start loading ad in background. adview.loadad(adrequest); 

you told fldcontainer matchparent. means consume space of parent, leaving none ad.

instead try:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <linearlayout         android:id="@+id/flcontainer"                <!-- data layout -->         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_weight="1"         android:orientation="vertical" />      <linearlayout         android:id="@+id/ad_layout"                  <!-- admob layout -->         android:layout_width="match_parent"         android:layout_height="50dp"         android:orientation="vertical" />  </linearlayout> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -