Placing an advertisement in a banner so that it sits below and separately from ViewPager

I have a ViewPager with 3 fragments,

enter image description here

At the bottom of each snippet, I posted a Banner ad.

What I would like is to have one ad at the bottom of the entire presentation, and not one in each snippet

enter image description here

Thus, I need to load only one ad, and it always fits at the bottom of the screen.

My activity in ViewPager is where I think the banner ad should go, but I don’t know how to move it.

<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:label="@string/app_name"
android:layout_width="match_parent"
android:layout_height="match_parent">   
</android.support.v4.view.ViewPager>

ad that is currently in Frags

<com.google.android.gms.ads.AdView
        android:id="@+id/adMainViewTrial"
        android:layout_width="320dp"
        android:layout_height="50dp"
        android:layout_marginTop="16dp"
        ads:adSize="BANNER"
        ads:adUnitId="My Id" >
</com.google.android.gms.ads.AdView>

Hope I figured it out. I still have a subtle understanding of what I'm doing here, so all help is certainly appreciated.

enter image description here

Here is a picture of my application as

+4
1

, .

ViewPager

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:label="@string/app_name" >
    </android.support.v4.view.ViewPager>

    <com.google.android.gms.ads.AdView
        android:id="@+id/adMainViewTrial"
        android:layout_width="320dp"
        android:layout_height="50dp"
        android:layout_marginTop="16dp"
        ads:adSize="BANNER"
        ads:adUnitId="My Id" >
    </com.google.android.gms.ads.AdView>

</LinearLayout>

MyViewPagerActivity.

, .

+1

Source: https://habr.com/ru/post/1612144/


All Articles