简体   繁体   中英

RecyclerViews inside ScrollView is cutting off the last item

I have a ScrollView with a LinearLayout, and several different RecyclerView inside because I load data from different sources.

<?xml version="1.0" encoding="utf-8"?>    
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/posts_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:clipToPadding="false"
        android:padding="10dp"
        android:layout_marginTop="20dp"
        android:nestedScrollingEnabled="false"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/movies_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:clipToPadding="false"
        android:padding="10dp"
        android:layout_marginTop="20dp"
        android:nestedScrollingEnabled="false"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/tv_shows_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:clipToPadding="false"
        android:padding="10dp"
        android:layout_marginTop="20dp"
        android:nestedScrollingEnabled="false"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/music_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:clipToPadding="false"
        android:padding="10dp"
        android:layout_marginTop="20dp"
        android:nestedScrollingEnabled="false"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/books_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:clipToPadding="false"
        android:padding="10dp"
        android:layout_marginTop="20dp"
        android:nestedScrollingEnabled="false"/>

</LinearLayout>

I use both LinearLayoutManager and GridLayoutManager to organise the content showed by the recyclerviews.

    GridLayoutManager layoutManager = new GridLayoutManager(context, 2);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);

For some reason, the last element of the second RecycleView (with a GridLayout) is getting cut off.

在此处输入图片说明

While elements of the other RecycleViews are showed in the correct way.

在此处输入图片说明

I don't know if it is important, but inside the RecycleViews I use CardViews.

Any help would be greatly appreciated since I am going nuts with this problem :(


SOLUTION

The solution is simple: I just used NestedScrollView instead of ScrollView and it works fine.

在这种情况下,请使用嵌套滚动视图而不是滚动视图。

在线性布局上放置底边距将解决您的问题。底边距应为回收站视图行的高度尺寸。

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