4

Before digging into the code, I've already checked the following questions:

  1. How to use RecyclerView inside NestedScrollView?
  2. Recyclerview inside Nested Scrollview scroll but does not fast scroll like normal Recyclerview or Nested Scrollview
  3. RecyclerView inside a ScrollView/NestedScrollView does not scroll properly

None of the aforementioned questions has worked with me. The RecyclerView is too laggy when scrolling.

I have a NestedScrollview and a LinearLayout as a main Layout for the NestedScrollview. Layout's code is:

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:fbutton="http://schemas.android.com/apk/res-auto" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center" > <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/frag_misc_rv_margin_top" android:scrollbars="none" android:nestedScrollingEnabled="false" android:id="@+id/frag_showcase_promotion_recyclerview"/> </LinearLayout> </android.support.v4.widget.NestedScrollView> 

The code is:

mPromotionsRv.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.HORIZONTAL,false)); mPromotionsRv.setNestedScrollingEnabled(false); mPromotionsAdapter = new ShowcasePromotionRvAdapter(getActivity(), mPromotionsItems); mPromotionsAdapter.setOnItemClickListener(new ShowcasePromotionListener() { @Override public void onClick(View view, int position) { ItemPromotion mPromotion = mPromotionsItems.get(position); try{ recordPromotionClick(mPromotion.getId()); view.getContext().startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(mPromotion.getPromotion_link()))); } catch (Exception e){ e.printStackTrace(); } } }); mPromotionsRv.setAdapter(mPromotionsAdapter); SnapHelper snapHelperStart = new GravitySnapHelper(Gravity.START); snapHelperStart.attachToRecyclerView(mPromotionsRv); RecyclerView.ItemAnimator animator = mPromotionsRv.getItemAnimator(); if (animator instanceof SimpleItemAnimator) { ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false); } 
2
  • Essentially no matter what, using wrap_content with RecyclerView is always going to risk using too many resources. Commented Jul 4, 2018 at 2:09
  • I've tried setting the height and didn't really help at all. Commented Jul 4, 2018 at 4:05

1 Answer 1

0

Since your RecyclerView is Horizontal, try making your RecyclerView's width "wrap_content".

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.