4

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.

enter image description here

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

enter image description here

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.

Mattia Campana
  • 509
  • 2
  • 6
  • 15
  • 1
    https://stackoverflow.com/q/27083091/5132444 this should help you. – Jude Fernandes Mar 23 '18 at 19:28
  • 1
    Just a suggestion i think you should consider using `RecyclerView` with horizontal `Layoutmanager` for this typeof arrangement other than `Grid`. – ADM Mar 23 '18 at 19:34
  • @MattiaCampana np, can you mark the answer as correct so future viewers can directly get to the post. – Jude Fernandes Mar 23 '18 at 20:40
  • 1
    Possible duplicate of [RecyclerView inside ScrollView is not working](https://stackoverflow.com/questions/27083091/recyclerview-inside-scrollview-is-not-working) – Selvin Mar 23 '18 at 22:36
  • The answer can be found at [RecyclerView inside ScrollView is not working ](http://stackoverflow.com/q/27083091/5132444) – Jude Fernandes Mar 23 '18 at 20:39

2 Answers2

2

Use the Nested Scroll View instead of Scroll View in this situation.

asim mehmood
  • 121
  • 10
-1

putting a bottom margin on linear layout will solve your problem.The bottom margin should be the height size of recycler view row.