目前AdView
出現在ViewPager
的內部,因此它阻止了應用中的內容。我怎樣才能讓AdView
出現在ViewPager
的下面,而不是裏面。如何在CoordinatorLayout的Viewpager下面獲取Adview
我試圖將AdView
放在ViewPager
下面的RelativeLayout
中,但之後AdView
完全不顯示。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.candyx.testapp.Activity">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/main_button_background">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabGravity="fill"
app:tabIndicatorColor="@color/colorTabIndicator"
app:tabIndicatorHeight="3dp"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"
android:layout_gravity="center|bottom"/>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
這個問題是,現在它推動了內容和工具欄下的橫幅大小,所以我認爲它的新協調員佈局,不想一起玩。我真的不希望它嵌套在viewpager裏面,但我想現在唯一的解決方案是在我的recyclerview上放置橫幅大小的底部填充 –
檢查編輯..... –
沒有它仍然在viewpager的底部,但它沒關係只是使用recyclerview的底部填充,所以當你滾動到底部有一個空白的廣告 –