0

i have

MAIN VIEW

<ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_products" android:layout_width="match_parent" android:layout_height="wrap_content" android:nestedScrollingEnabled="false" /> </ScrollView> 

On my template adapter, i have a another recycler adapter for child views

<?xml version="1.0" encoding="utf-8"?> <androidx.cardview.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightSum="1"> <TextView android:id="@+id/title_product" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight=".2" android:background="@color/GRAY" android:text="TextView" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_for_specification_items" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="visible" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" android:nestedScrollingEnabled="false" /> </LinearLayout> </androidx.cardview.widget.CardView> 

The code work, but when user scroll on android device, the parent scrollView does not allow me to scroll over the recycler view (1)

0

3 Answers 3

2

Use NestedScrollview instead of scrollview and use android:nestedScrollingEnabled="false" for recycler_products recyclerview not in both

 <androidx.core.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_products" android:layout_width="match_parent" android:layout_height="wrap_content" android:nestedScrollingEnabled="false" /> </androidx.core.widget.NestedScrollView> 
Sign up to request clarification or add additional context in comments.

Comments

1

If you are not able to scroll it is because of this line

android:nestedScrollingEnabled="false".

Change it to True, so you can enable the scrolling:

android:nestedScrollingEnabled="true".

Comments

0

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> 

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.