0

I'm using the latest support design (compile 'com.android.support:design:+') which from 23.2 should have fixed the issue with RecyclerView inside ScrollView. The RecyclerView and the ExpandableListView scrolling both work perfectly. But when the ExpandableListView is too long and I want to be able to scroll the layout upwards so I could see the rest of it, the scrollview just doesn't work.

fragment :

 myRecyclerView = (RecyclerView) view.findViewById(R.id.myRecyclerView); myRecyclerView.setNestedScrollingEnabled(false); LinearLayoutManager layoutManager = new LinearLayoutManager( mContext, LinearLayoutManager.HORIZONTAL, false ); layoutManager.setAutoMeasureEnabled(true); myRecyclerView.setLayoutManager(layoutManager); MyListAdapter myListAdapter = new MyListAdapter(recyclerDataList, getActivity()); myRecyclerView.setAdapter(myListAdapter); 

xml:

 <ScrollView android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:fillViewport="true"> <RelativeLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" > <TextView android:id="@+id/headerText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="header text" android:layout_marginRight="10dp"/> <android.support.v7.widget.RecyclerView android:id="@+id/myRecyclerView" android:layout_below="@id/headerText" android:scrollbars="none" android:layout_width="match_parent" android:layout_height="wrap_content"/> <ExpandableListView android:id="@+id/expandableList" android:layout_below="@id/myRecyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:divider="1dp" android:dividerHeight="0dp" android:groupIndicator="@null" android:listSelector="@android:color/transparent" android:showDividers="middle" > </ExpandableListView> </RelativeLayout> </ScrollView> 
1
  • that is not a duplicate. My recyclerview works fine, the problem is the scrollview tha thosts the recyclerview. Commented May 3, 2016 at 12:51

2 Answers 2

0

You need to calculate listview height at run time, can not use listview or expendable listview inside scroll view like this.

Android list view inside a scroll view

Sign up to request clarification or add additional context in comments.

Comments

0

You should do this way:

Implement OnItemTouchListener of RecyclerView and disallow parent touch event on ACTION_MOVE.

recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() { @Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { int action = e.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: recyclerView.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: recyclerView.getParent().requestDisallowInterceptTouchEvent(false); break; case MotionEvent.ACTION_MOVE: recyclerView.getParent().requestDisallowInterceptTouchEvent(true); break; } return false; } @Override public void onTouchEvent(RecyclerView rv, MotionEvent e) { } @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { } }); 

Hope this will help you.

3 Comments

Unfortunately it doesn't work :/
@BVtp, I have edited my answer, please check
Thanks for your help. Unfortunately it didn't help either.. I'm so frustrated.. Been on it for so much on it now:/

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.