0

My banner Ad is not appearing at the bottom when I run it on my app but on the Design section in android studio it appears at the bottom.

Below is my xml layout code:

 <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
    xmlns:maxads="http://schemas.applovin.com/android/1.0"
    android:layout_width="match_parent"
    android:background="@color/colorThemeWhite"
    android:layout_height="match_parent"
    tools:context="com.emiloancalculator.loanplanner.MainActivity">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:elevation="0dp"
            android:theme="@style/AppTheme.AppBarOverlay">
            <RelativeLayout
                android:background="@color/colorMain"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <androidx.appcompat.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="60dp"
                    android:gravity="center_vertical"
                    app:titleTextAppearance="@style/Title"
                    android:background="@color/colorMain"
                    app:title="@string/app_name"
                    android:elevation="0dp"
                    />
                <ImageView
                    android:id="@+id/favMenu"
                    android:backgroundTint="@color/colorWhite"
                    android:background="@drawable/ic_baseline_favorite_border_24"
                    android:layout_width="22dp"
                    android:layout_alignParentRight="true"
                    android:layout_margin="20dp"
                    android:layout_height="22dp"/>
            </RelativeLayout>


            <com.google.android.material.tabs.TabLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tabLayout"
                
                app:tabIndicatorColor="@color/colorWhite"
                app:tabTextAppearance="@style/ForTabLayout"
                app:tabTextColor="@color/colorWhite"
                android:scrollbars="none"
                android:elevation="0dp"
                android:background="@color/colorMain"
                android:orientation="horizontal">
            </com.google.android.material.tabs.TabLayout>

        </com.google.android.material.appbar.AppBarLayout>


        <androidx.viewpager2.widget.ViewPager2
            android:layout_marginTop="10dp"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="50dp"
            android:id="@+id/viewPager"/>

    </LinearLayout>


    <com.applovin.mediation.ads.MaxAdView
        maxads:adUnitId="deb0327b3f01cdb9"
        android:background="@color/banner_background_color"
        android:layout_width="match_parent"
        android:layout_gravity="bottom"
        android:layout_height="@dimen/banner_height" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

This is an issue I have encountered with several apps... The others I have not posted because they appear fully at the top but this app it displays the Banner ad at the top but I can only see a quarter of it.

agega
  • 157
  • 3
  • 13

1 Answers1

0

You still must call loadAd() on the MaxAdView you create in this way:

MaxAdView adView = findViewById( R.id.ad_view );
adView.loadAd();

Do this in the same class as you initialized your layout.xml.

S. Gissel
  • 1,788
  • 2
  • 15
  • 32