0

I am using android studio to develop my app and I am trying to add a banner ad to my app but I don't know why my banner ad is not sitting under the app page and instead is covering the bottom part of my app. I want the user to be able to see the whole page and for it to not be covered by the banner ad. I want the banner ad to have its separate space, centered at the bottom of my app not covering the app page itself. How do I do this?

This is my current xml code for my banner ad:

<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            ads:adSize="BANNER"
            ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
            android:layout_centerHorizontal="true"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent">
        </com.google.android.gms.ads.AdView>

And this is all of the code in my activity_main.xml:

 <?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawer_layout"
    android:fitsSystemWindows="true"
    tools:openDrawer="start"
    tools:context=".MainActivity">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:elevation="4dp"
            android:background="#6666ff"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize">

        </androidx.appcompat.widget.Toolbar>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".MainActivity">

            <ImageButton
                android:id="@+id/imaget"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/black"
                android:scaleType="fitXY"
                android:scaleX="1.1"
                android:scaleY="1.0"
                android:src="@drawable/pic_one"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.0"></ImageButton>

            <com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
                android:id="@+id/adView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                ads:adSize="BANNER"
                ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
                android:layout_centerHorizontal="true"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent">
            </com.google.android.gms.ads.AdView>


        </androidx.constraintlayout.widget.ConstraintLayout>
    </LinearLayout>

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_gravity="start"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/navigation_menu"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"/>


    
</androidx.drawerlayout.widget.DrawerLayout>

What changes to do I need to make to my code to solve the problem that I'm currently facing?

Marfog509
  • 37
  • 3

0 Answers0