So, I have a horizontal RecyclerView inside a vertical ScrollView. Everything inside my layout is displayed perfectly, and everything scrolls in the directions I want, and it does it smoothly.
The only problem I encountered is that the RecyclerView is under some other content in the ScrollView, and when the RecyclerView is partially displayed, it will align the bottom of the RecyclerView with the bottom of the screen at startup. This means that the content above the RecyclerView is being squeezed out of the screen.
Does anyone know why this is happening, and how can I fix it?
Here is a simple layout that does what I just described. You don't even need to populate a RecyclerView, it will do it anyway.
<?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="match_parent"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="500dp" android:background="#fff"/> <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="200dp" android:background="#000"/> </LinearLayout> </ScrollView>
source share