Recyclerview Inside Scrollview, Some Items Are Not Shown
I had a RecyclerView in ScrollView like this:
Solution 1:
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
.
Solution 2:
The best solution is to keep multiple Views
in a Single View / View Group
and then keep that one view in the SrcollView. ie.
Format -
<ScrollView><AnotherView><RecyclerView><TextView><AndOtherViews>
</Another View>
</ScrollView>
Eg.
<ScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:text="any text"android:layout_width="match_parent"android:layout_height="wrap_content"/><TextViewandroid:text="any text"android:layout_width="match_parent"android:layout_height="wrap_content"/></ScrollView>
Another Eg. of ScrollView with multiple Views
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"><LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="1"><androidx.recyclerview.widget.RecyclerView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"/><LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="10dp"
android:orientation="vertical"><TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/CategoryItem"
android:textSize="20sp"
android:textColor="#000000"/><TextView
android:textColor="#000000"
android:text="₹1000"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/><TextView
android:textColor="#000000"
android:text="so\nugh\nos\nghs\nrgh\n
sghs\noug\nhro\nghreo\nhgor\ngheroh\ngr\neoh\n
og\nhrf\ndhog\n
so\nugh\nos\nghs\nrgh\nsghs\noug\nhro\n
ghreo\nhgor\ngheroh\ngr\neoh\nog\nhrf\ndhog"
android:layout_width="match_parent"
android:layout_height="wrap_content"/></LinearLayout></LinearLayout></ScrollView>
Post a Comment for "Recyclerview Inside Scrollview, Some Items Are Not Shown"