Nah*_*hue 6 android admob android-layout android-recyclerview
我有一个RelativeLayout在至极我有一个RecyclerView和LinearLayout具有AdView内.在RecyclerView有很多的项目,当我无法向他们展示在屏幕上我不得不向下滚动才能看到他们,但现在,我添加了LinearLayout附加到与屏幕的底部AdView我向下滚动内,我不能看到最后一项RecyclerView.我正在附加LinearLayout到底部,但它似乎在它之上RecyclerView,我希望RecyclerView在屏幕上显示项目但不在后面LinearLayout.可能吗?
这是我的布局XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.RecyclerView
android:id="@+id/rvGeneric"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center">
<com.google.android.gms.ads.AdView
android:id="@+id/adViewBaseRefresh"
android:layout_width="fill_parent"
android:layout_height="53dp"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"
android:layout_marginBottom="3dp">
</com.google.android.gms.ads.AdView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
相对布局需要在 XML 中定义“相对”关系。由于您没有任何(除了在底部对齐线性布局之外),结果是 LL 和 RecyclerView 重叠。
将行 android:layout_below="@id/rvGeneric" 添加到线性布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ll_ad"
android:layout_alignParentBottom="true"
android:gravity="center">
<com.google.android.gms.ads.AdView
android:id="@+id/adViewBaseRefresh"
android:layout_width="fill_parent"
android:layout_height="53dp"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"
android:layout_marginBottom="3dp">
</com.google.android.gms.ads.AdView>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rvGeneric"
android:layout_above="@id/ll_ad"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
856 次 |
| 最近记录: |