Can I add Admob banner in every item in ViewPager2 items?

69 views Asked by At

Is it possible to add Admob banner in every Items xml for showing in ViewPager2? So when user scrolling to down or up the ViewPager2 every time Admob will be seen? It is my xml

It is a simple item row

  <TextView
        android:id="@+id/textView17"
        android:layout_width="189dp"
        android:layout_height="40dp"
        android:gravity="center"
        android:text="username"
        android:textColor="@color/black"
        app:layout_constraintBottom_toTopOf="@+id/adView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />
    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        ads:layout_constraintBottom_toBottomOf="parent"
        ads:layout_constraintStart_toStartOf="parent"
        ads:layout_constraintEnd_toEndOf="parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
    </com.google.android.gms.ads.AdView>

    <ImageView
        android:id="@+id/imageView20"
        android:layout_width="279dp"
        android:layout_height="356dp"
        app:layout_constraintBottom_toTopOf="@+id/textView17"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:srcCompat="@tools:sample/avatars" />
1

There are 1 answers

2
user16930239 On

Technically you can do this, but AdMob Discourages showing 2 banners on the screen at any given time, which may occur if you have this implementation. Also Admob SDK will make the banner disappear if it created two banner at the same time.

My Recommendation: is to have a buffer between items (for example: show the banner on every 5th item)