I am using recyclerview in my project but bottom items are not displayed in recyclerview.
I tried ScrollView but my app is crashing it shows java.lang.IllegalStateException: ScrollView can host only one direct child
this error.
CodePudding user response:
I think you use the recyclerview as parent layout that this work is wrong, because recyclerview in android just get a adapter that it, and you most use the container layout like scrollbars for show another layout inside it.
CodePudding user response:
You have added more than one ViewGroup
as a child of your ScrollView
. ScrollView
must contain at most one child in order to properly calculate the height of the view.
Below sample code is wrong:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
....
....
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
....
....
</LinearLayout>
</ScrollView>
In order to solve the problem, you can use the below sample code:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- here add your views -->
....
....
</LinearLayout>
</ScrollView>