Recycler View ниже Recycler View, но не после половины - PullRequest
0 голосов
/ 05 июля 2018

Мне нужна страница с двумя списками (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>

1 Ответ

0 голосов
/ 05 июля 2018

Попробуйте это

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