Для начала я знаю проблемы Recycler в старых версиях libs. Моя текущая версия lib - 24.2.1.RecyclerView with ScrollView проблемы с wrap_content
Я пытаюсь создать шаблон, который содержит основную информацию об этом элементе, а ниже этой информации - список комментариев. Этот список комментариев должен обернуть его содержимое и должен прокручиваться с его родителем, поэтому он должен выглядеть как один большой вид.
Я пытаюсь сделать это со следующим кодом, но RecyclerView не обертывает контент, вместо этого он имеет небольшую часть в нижней части экрана.
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="50dp">
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/news_layout_header_repost"/>
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/cardview_inner_margin"
android:layout_marginEnd="@dimen/cardview_inner_margin"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="@+id/repostTextLayout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/loadComments"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</ScrollView>
</LinearLayout>
Можете ли вы мне помочь?
ОБНОВЛЕНИЕ Наконец-то нашли решение. Лучше использовать относительную компоновку. Не знаю, почему эта проблема возникла в LinearLayout, но следующая структура XML работала:
<ScrollView>
<RelativeLayout>
<LinearLayout/>
<RecyclerView/>
</RelativeLayout>
</ScrollView>
У вас есть ответ, у меня также такая же проблема. – YBDevi