Reputation: 435
How to get AdMob banner to show up at the bottom of the app? I tried different methods that were posted here and no matter what I do the ad appears on top of the app. What am I doing wrong?
Here is what my layout looks like
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="${relativePackage}.${activityClass}" >
<EditText
android:id="@+id/vinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:ems="7"
android:gravity="center"
android:inputType="textCapCharacters"
android:maxLength="7"
android:selectAllOnFocus="true" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/vinText"
android:layout_centerHorizontal="true"
android:onClick="sendVIN"
android:text="@string/button_send" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="ID" >
</com.google.android.gms.ads.AdView>
</LinearLayout>
</RelativeLayout>
Upvotes: 0
Views: 197
Reputation: 26198
You need to specify the location of the linearlayout
to the relativelayout
, android:layout_centerHorizontal
will only place it to the middle of the screen but top of any other child views of the RelativeLayout
solution
you need to call android:layout_alignBottom
to true to align the LinearLayout to the bottom of the View
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center" >
Upvotes: 1