如下图所示。我在回收者视图上方有一个布局,下面有一个布局。两个标签都是线性布局。我面临两个问题。
答案 0 :(得分:0)
您可以将两个LinearLayouts作为页眉和页脚视图添加到RecyclerView。这个问题的最佳答案应该让您知道如何做到这一点:RecyclerView header and footer
答案 1 :(得分:0)
如果您的两个LinearLayout具有固定大小,您可以将它们固定在RelativeLayout中,然后在"之间插入您的RecyclerView"。
<RelativeLayout>
<LinearLayout alignParentTop="true" height="100dp" id="@+id/topLayout"/>
<LinearLayout alignParentBottom="true" height="100dp" id="@+id/bottomLayout"/>
<RecyclerView height="match_parent" above="@id/bottomLayout" below="@id/topLayout"/>
</RelativeLayout>
或者,如果您的顶部容器是LinearLayout,您可以使用权重(1表示顶部LinearLayout,1表示底部LinearLayout,3表示RecyclerView)
<LinearLayout orientation="vertical">
<LinearLayout height="0dp" weight="1"/>
<RecyclerView height="0dp" weight="3"/>
<LinearLayout height="0dp" weight="1"/>
</LinearLayout>