Question

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">
Was it helpful?

Solution

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"
                   />

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top