Why my Admob banner is showing on top of screen?

494 Views Asked by At

I have an app with two ads: a banner and an interstitial. I have a RelativeLayout where I have a GridLayout and the AdView. The grid layout has the line android:layout=above the AdView and the AdView has the line alignparentbottom="true" But it keeps showing the banner on top of the screen.

I need to place the AdView just at bottom of screen.

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:color/background_light"
tools:context=".MainActivity">

<TextView
    android:id="@+id/tvcifra"
    android:layout_width="709dp"
    android:layout_height="93dp"
    android:layout_above="@id/gridlayout"
    android:layout_alignTop="@id/tvcifra"
    android:textColor="@android:color/holo_blue_light"
    android:textSize="48sp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<androidx.gridlayout.widget.GridLayout
    android:id="@+id/gridlayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="0dp"
    android:layout_marginLeft="0dp"
    android:layout_marginTop="90dp"
    android:layout_marginEnd="0dp"
    android:layout_marginRight="0dp"
    android:layout_marginBottom="0dp"
    android:layout_above="@id/adView4"
    app:columnCount="6"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@id/tvcifra"
    app:orientation="vertical"
    app:rowCount="6">

    elements of grid layout


</androidx.gridlayout.widget.GridLayout>

<com.google.android.gms.ads.AdView
    android:id="@+id/adView4"
    android:layout_width="659dp"
    android:layout_height="48dp"
    android:layout_alignParentBottom="true"
    android:layout_marginTop="0dp"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-2703074771097768/1520884519" />
1

There are 1 best solutions below

3
Bilal Rammal On

try adding a layout_gravity to your banner ad xml

<com.google.android.gms.ads.AdView
android:id="@+id/adView4"
android:layout_width="659dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginTop="0dp"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-2703074771097768/1520884519" />