-1

I am trying to add adview in my application. The problem is adview is getting displayed next to the buttons and not in the bottom end of the screen, i tried android:layout_gravity="bottom" but it has no effect, the parent layout is linear layout.

 <com.google.ads.AdView android:id="@+id/ad"
                       android:layout_width="fill_parent"
                       android:layout_height="wrap_content"
                       ads:adSize="BANNER"
                       android:layout_gravity="bottom"
                       ads:adUnitId="xxxxxxxxxxx"
                       ads:testDevices="TEST_EMULATOR"
                       ads:loadAdOnCreate="true"/>


<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:layout_height="wrap_content">
Psypher
  • 10,717
  • 12
  • 59
  • 83

2 Answers2

1

You can simple set :

<com.google.ads.AdView android:id="@+id/ad"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   ads:adSize="BANNER"
                   android:gravity="bottom"
                   ads:adUnitId="xxxxxxxxxxx"
                   ads:testDevices="TEST_EMULATOR"
                   ads:loadAdOnCreate="true"/>

or You can set in LinearLayout:

<LinearLayout android:id="@+id/ad"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="bottom"
                   />
Shani Goriwal
  • 2,111
  • 1
  • 18
  • 30
0

Try putting an imageView in the gap, which is ofcourse transparent. As you want the ad to be placed at the end, and in linearLayout you cannot leave empty space, so use an imageview for the extra place and below the imageView put the Adview

Eric B.
  • 4,622
  • 2
  • 18
  • 33