回收商视图下方的回收商视图,但不是在一半之后



我想要一个包含两个列表(RecyclerView(的页面,每个列表都有一个标题(TextView(,一个在前一个列表结束之后开始。但我希望每个最多有一半的页面。因此,在第一个列表有一个项目的情况下,第二个列表将直接放在下面,如果第一个列表很长,它只会占用一半的页面,第二个列表将从后半部分开始。这是为了如果我希望每个总是占一半

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/list_one"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/list_two"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>

试试这个

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/list_header"
android:background="@color/header"
android:gravity="center"
android:text="@string/find_friends__already_playing"
android:visibility="visible" />
<android.support.v7.widget.RecyclerView
android:id="@+id/in_app_friends"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="@color/white"/>
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/list_header"
android:background="@color/find_friends__header"
android:gravity="center"
android:text="@string/find_friends__invite_friends" />
<android.support.v7.widget.RecyclerView
android:id="@+id/friends_to_invite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"/>
</LinearLayout>
</ScrollView>

最新更新