无法将视图放置在RecyclerView下方

我在将Adview放在RecyclerView下面时遇到问题。目前,RecyclerView占据了布局的其余部分,而Adview没有显示。我在网上找到的解决方案都没有解决我的问题。通常layout\u weight或下面的layout\u可以解决问题,但在这种情况下并非如此

XML

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android"
xmlns:tools=”http://schemas.android.com/tools"
android:layout\u width=“匹配父项”
android:layout\u height=“match\u parent”
xmlns:ads=”http://schemas.android.com/apk/res-auto"
工具:context=“.MainActivity”>
<相对布局
android:layout\u width=“匹配父项”
android:layout\u height=“match\u parent”
android:background=“#7c7c”
android:focusable=“true”
android:focusableInTouchMode=“true”>
<android.support.v7.widget.RecyclerView
android:id=“@+id/recycler\u视图”
android:layout\u width=“匹配父项”
android:layout\u height=“包装内容”
android:layout_lower=“@+id/relContainer”
android:background=“@drawable/bordershadow2”
android:paddingBottom=“17dp”
android:paddingLeft=“@dimen/activity\u水平\u边距”
android:paddingRight=“@dimen/activity\u水平\u边距”
android:paddingTop=“10dp”/>
<com.google.android.gms.ads.AdView
android:id=“@+id/adView”
android:layout\u width=“fill\u parent”
android:layout\u height=“包装内容”
android:layout_lower=“@+id/recycler_视图”
ads:adSize=“BANNER”
ads:adUnitId=“ca-app-pub-3940256099942544/630978111”>
&lt/com.google.android.gms.ads.AdView>
<相对布局
android:id=“@+id/relContainer”
android:layout\u width=“包装内容”
android:layout\u height=“包装内容”
android:background=“@drawable/bordershadow”
android:paddingLeft=“@dimen/activity\u水平\u边距”
android:paddingRight=“@dimen/activity\u水平\u边距”
android:paddingTop=“@dimen/activity\u vertical\u margin”>
<表格布局
android:id=“@+id/purchaseTableLayout”
android:layout\u width=“包装内容”
android:layout\u height=“包装内容”
android:paddingBottom=“7dp”
android:paddingTop=“7dp”
android:layout\u alignParentTop=“true”
android:stretchColumns=“0,1,2”>
<桌椅
android:layout\u width=“包装内容”
android:layout\u height=“包装内容”
android:weightSum=“3”>
<文本框
android:id=“@+id/textView1”
android:layout_width=“0dp”
android:layout\u height=“match\u parent”
android:layout_weight=“1”
android:gravity=“中心垂直”
android:paddingLeft=“2dp”
android:singleLine=“true”
android:textColor=“#000”
android:textSize=“24sp”
android:textStyle=“bold”/>
<文本框
android:id=“@+id/textView2”
android:layout_width=“0dp”
android:layout\u height=“match\u parent”
android:layout_weight=“1”
android:gravity=“中心垂直”
android:paddingLeft=“2dp”
android:singleLine=“true”
android:textColor=“#000”
android:textSize=“24sp”
android:textStyle=“bold”/>
<纺纱机
android:id=“@+id/typeSpinner”
style=“style/Theme.Material”
android:layout_width=“0dp”
android:layout\u height=“match\u parent”
android:layout_weight=“1”
android:gravity=“中心垂直”
android:entries=“@array/type_array”
android:textSize=“@dimen/title\u size”/>
&lt/TableRow>
&lt/表格布局>
<编辑文本
android:id=“@+id/searchEditText”
android:layout\u width=“fill\u parent”
android:layout\u height=“包装内容”
android:layout\u centerHorizontal=“true”
android:layout_lower=“@+id/purchaseTableLayout”
android:digits=“abcdefghijklmnopqrstuvxyzabdfghijklmnopqrstuvxyz'()”
android:hint=“搜索”
android:imeOptions=“actionDone”
android:singleLine=“true”/>
<表格布局
android:id=“@+id/tableLayout”
android:layout\u width=“包装内容”
android:layout\u height=“包装内容”
android:layout_below=“@+id/searchEditText”
android:paddingBottom=“7dp”
android:paddingTop=“7dp”
android:stretchColumns=“0,1,2”>
<桌椅
android:layout\u width=“包装内容”
android:layout\u height=“包装内容”
android:weightSum=“3.0”>
<纺纱机
android:id=“@+id/sortRaceSpinner”
style=“style/Theme.Material”
android:paddingTop=“5dp”
android:paddingBottom=“10dp”
android:layout_width=“0dp”
android:layout\u height=“match\u parent”
android:layout_weight=“1.0”
android:entries=“@array/sort\u race\u array”
android:textSize=“@dimen/title\u size”/>
<纺纱机
android:id=“@+id/sortAffinitySpinner”
style=“style/Theme.Material”
android:paddingTop=“5dp”
android:paddingBottom=“10dp”
android:layout_width=“0dp”
android:layout\u height=“match\u parent”
android:layout_weight=“1.0”
android:entries=“@array/sort\u affinity\u array”
android:textSize=“@dimen/title\u size”/>
<纺纱机
android:id=“@+id/sortSpinner”
style=“style/Theme.Material”
android:paddingTop=“5dp”
android:paddingBottom=“10dp”
android:layout_width=“0dp”
android:layout\u height=“match\u parent”
android:layout_weight=“1.0”
android:entries=“@array/sort_array”
android:textSize=“@dimen/title\u size”/>
&lt/TableRow>
&lt/表格布局>
&lt/相对寿命>
&lt/相对寿命>
&lt/相对寿命>

我有一个视图,需要在一个动态大小的回收视图下。
这意味着随着RecyclerView的增长,视图将向下移动

我的解决方案是将paddingBottom添加到RecyclerView中,然后将相同值的负marginTop添加到视图中,效果非常好

<线性布局
android:orientation=“垂直”
android:layout\u width=“匹配父项”
android:layout\u height=“match\u parent”>
<android.support.v7.widget.RecyclerView
android:paddingBottom=“48dp”
android:layout\u width=“匹配父项”
android:layout\u height=“包装内容”
/&燃气轮机;
<文本框
android:layout_marginTop=“-48dp”
android:layout\u width=“匹配父项”
android:layout\u height=“包装内容”
/&燃气轮机;
&lt/线性布局>

发表评论