RecyclerView inside ScrollView is not working
use NestedScrollView
instead of ScrollView
Please go through NestedScrollView reference document for more information.
and add recyclerView.setNestedScrollingEnabled(false);
to your RecyclerView
Recyclerview inside ScrollView not scrolling smoothly
Try doing:
RecyclerView v = (RecyclerView) findViewById(...);
v.setNestedScrollingEnabled(false);
As an alternative, you can modify your layout using the support design library. I guess your current layout is something like:
<ScrollView >
<LinearLayout >
<View > <!-- upper content -->
<RecyclerView > <!-- with custom layoutmanager -->
</LinearLayout >
</ScrollView >
You can modify that to:
<CoordinatorLayout >
<AppBarLayout >
<CollapsingToolbarLayout >
<!-- with your content, and layout_scrollFlags="scroll" -->
</CollapsingToolbarLayout >
</AppBarLayout >
<RecyclerView > <!-- with standard layoutManager -->
</CoordinatorLayout >
However this is a longer road to take, and if you are OK with the custom linear layout manager, then just disable nested scrolling on the recycler view.
Edit (4/3/2016)
The v 23.2
release of the support libraries now includes a factory “wrap content” feature in all default LayoutManager
s. I didn’t test it, but you should probably prefer it to that library you were using.
<ScrollView >
<LinearLayout >
<View > <!-- upper content -->
<RecyclerView > <!-- with wrap_content -->
</LinearLayout >
</ScrollView >
ScrollView inside RecyclerView won't scroll
I solved it by adding a line to rafsanahmad007's solution:
ScrollView scrollView = (ScrollView)findViewById(R.id.scrollView1);
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
// Disallow the touch request for parent scroll on touch of child view
view.getParent().requestDisallowInterceptTouchEvent(false);
view.onTouch(motionEvent);
return true;
}
});
I'm not sure that's how View.onTouch
is called on Java, as I'm developing with Xamarin.Android (C#). It should be pretty similar.
RecyclerView inside ScrollView, some items are not shown
I found the solution myself: replace ScrollView
with NestedScrollView
and keep recyclerView.setNestedScrollingEnabled(false)
. I don't know if this is what NestedScrollView
is made for but it works.
NOTICE:
NestedScrollView
is not a child ofScrollView
but ofFrameLayout
.- This solution will also bring some bugs with self-simulated
adjustResize
.
Android recycler view inside on scrollview
In you code you have recylerview inside scroll view, this is wrong.
Option 1: If scroll view has not any other child view than remove it and just use recyclerview and also remove android:nestedScrollingEnabled="false
And your Main View code looks like this;
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_products"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
Option 2: If scroll view has also other child including recyclerview than you should use nestedscrollview like below code:
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical">
<ImageView
android:id="@+id/sellerProduct"
android:layout_width="match_parent"
android:layout_height="200dp"
android:adjustViewBounds="true"
android:src="@drawable/iphone"
android:scaleType="fitXY"
android:contentDescription="@string/app_name" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:nestedScrollingEnabled="false
android:id="@+id/productList"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
Recyclerview inside Nested Scrollview scroll but does not fast scroll like normal Recyclerview or Nested Scrollview
try
recyclerView.setNestedScrollingEnabled(false);
recyclerview inside nested scroll view is not scolling
After many tries, I've found the solution
which is to change the recyclerView
's height to be wrap_content
instead of match_parent
or 0dp
so the recyclerView
would be like this:
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/profile_details_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_xxdim"
android:clipToPadding="false"
android:paddingBottom="@dimen/default_dim"
android:paddingStart="@dimen/default_dim"
android:nestedScrollingEnabled="false"
app:layout_constraintBottom_toBottomOf="parent"
android:focusable="false"
app:layout_constraintTop_toBottomOf="@id/profile_name"
/>
Related Topics
How to Get Extra Data from Intent on Android
Libraries Do Not Get Added to Apk Anymore After Upgrade to Adt 22
Retrieve a Fragment from a Viewpager
Install Application Programmatically on Android
Difference Between Gravity and Layout_Gravity in Android
How to Correctly Save Instance State of Fragments in Back Stack
Sending and Parsing Json Objects in Android
Running Multiple Asynctasks At the Same Time - Not Possible
Android List View Inside a Scroll View
Making Textview Scrollable on Android
Why 'Pageradapter::Notifydatasetchanged' Is Not Updating the View
Firebase Offline Capabilities and Addlistenerforsinglevalueevent
How to Have Multiple Styles Inside a Textview
Android: View.Setid(Int Id) Programmatically - How to Avoid Id Conflicts
"Debug Certificate Expired" Error in Eclipse Android Plugins