How to Add Multiple Admob ads in single activity?

30 views Asked by At

In this activity, I want to add multiple ads. but I am unable to do so. I want that in this activity, there should be an ad below the image, and one ad should be in the middle of the post's content. The ad below the image should be banner, and the one in the middle of the content should be native. For example, I have also attached a screenshot.

enter image description here

enter image description here

and also check java code of this activity from this link. Click Here

XML Activity Code

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bannerAdView"
        android:focusableInTouchMode="true">

        <ViewStub
            android:id="@+id/header_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
            android:id="@+id/swipe_refresh_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <RelativeLayout
                android:id="@+id/lyt_home_content"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <com.facebook.shimmer.ShimmerFrameLayout
                    android:id="@+id/shimmer_view_container"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:shimmer_duration="1000">

                    <ViewStub
                        android:id="@+id/shimmer_view_post_details"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                </com.facebook.shimmer.ShimmerFrameLayout>

                <androidx.core.widget.NestedScrollView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="fill_vertical"
                    android:clipToPadding="false"
                    android:fillViewport="true"
                    android:isScrollContainer="false"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior">

                    <include
                        android:id="@+id/lyt_main_content"
                        layout="@layout/include_post_detail"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />

                </androidx.core.widget.NestedScrollView>

                <include
                    android:id="@+id/lyt_failed_home"
                    layout="@layout/include_no_network"
                    android:visibility="gone" />

                <FrameLayout
                    android:id="@+id/customViewContainer"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:visibility="gone" />

            </RelativeLayout>

        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <com.solodroid.ads.sdk.ui.BannerAdView
        android:id="@+id/bannerAdView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>
0

There are 0 answers