简体   繁体   中英

Recycler View below Recycler View, but not after half

I want to have a page with two lists (RecyclerView) each with a header (TextView) one starting after the end of the previous. But I want each to have a maximum of half the page. So in a case where the first list has one item, the second list will be placed directly under, if the first list is long it will only take up half the page and the second list will start from the second half.This is for if I want each to always take up half

<?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>

Try this one

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM