Hiện tại, AdView
xuất hiện bên trong ViewPager
để chặn nội dung trong ứng dụng. Làm cách nào để có được AdView
xuất hiện bên dưới ViewPager
chứ không phải bên trong.Cách xem Adview bên dưới Viewpager trong CoordinatorLayout
Tôi đã cố gắng đặt AdView
trong một số RelativeLayout
bên dưới ViewPager
nhưng sau đó AdView
hoàn toàn không hiển thị.
<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>
Vấn đề là bây giờ nó đẩy nội dung lên và dưới thanh công cụ về biểu ngữ nên tôi nghĩ bố cục phối hợp mới của nó không muốn chơi cùng. Tôi không thực sự muốn nó lồng bên trong viewpager nhưng tôi đoán chỉ giải pháp cho đến nay là để đặt padding kích thước biểu ngữ trên recyclerview của tôi –
Kiểm tra Edit ..... –
Nope nó vẫn còn bên trong viewpager ở phía dưới nhưng nó ok bệnh chỉ cần sử dụng đệm dưới trên recyclerview vì vậy khi bạn cuộn xuống dưới cùng có một khoảng trống cho quảng cáo –