I have a ScrollView,
which contains a vertical LinearLayout.
This is a place, where I add some amount of Views called "Section". "Section" is a LinearLayout,
which contains a TextView
and `RecyclerView.
<ScrollView
android:id="@+id/main_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/sections_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>
section:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textSize="@dimen/activity_starred_title_textsize" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
The problem is that RecyclerView
is not truly wrap_content
sometimes. Therefore it creates 2 types of problems (depending on solution type I'm trying to use).
It can be unscrollable (so it matches screen height and I can't scroll it down to see rest of items inside).
It can scroll nested.
Originally problem is that it has nested scrolling. So I want RecyclerViews
to be as simple vertical LinearLayouts
and the only thing that has to have scrolling effect is root ScrollView.
What have I tried to do?
extend the
GridLayoutManager
and overridecanScrollVertically().
method:public boolean canScrollVertically(){ return false; }
extend
RecyclerView
class and override@Override public boolean onInterceptTouchEvent(MotionEvent event){ return false; }
@Override public boolean onTouchEvent(MotionEvent event){ return false; }
Disable
NestedScrolling
viaxml
everywhere, where it is possible.Override
GridLayoutManager
using this solution: SOLUTION- Combine 1-4