Reputation: 124
I have a ViewPager with 3 Fragments,
At the bottom of each fragment I have placed a Banner ad.
What I would like is to have one banner ad at the bottom of the entire view, instead of one in each fragment
This way I only have to load one ad, and it is always placed at the bottom of the screen.
My ViewPager Activity is where I think the Banner Ad should go, but I don't know how to move it into there.
<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 thats currently in the 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>
I hope I've made sense of this. I still only have a tenuous grasp on what i'm doing here, so all help is certainly appreciated.
Heres a picture of my app as is
Upvotes: 4
Views: 1059
Reputation: 1098
Please check it.
My ViewPager Activity
<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>
You can initialize ads in MyViewPagerActivity
.
I hope it will help you.
Upvotes: 2