How to add Recycler View inside the NestedScrollView which is placed inside a constraint layout, tried to add recycler view but not getting succesful
The problem that you have two direct views inside the NestedScrollView
, and There should be a single root layout within the `NestedScrollView, and then you can nest any other layout within this root.
To fix your problem, you have to wrap the LinearLayout
& the RecyclerView
within a root which is arbitrary picked as LinearLayout
:
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.MainFragment">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_default_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:fillViewport="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView13"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:srcCompat="@drawable/ic_baseline_person_add"
tools:layout_editor_absoluteX="13dp"
tools:layout_editor_absoluteY="14dp" />
<TextView
android:id="@+id/textView42"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:text="Received"
android:textSize="18sp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="450dp"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
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
Key Hash For Android-Facebook App
What Is the List of Supported Languages/Locales on Android
Navigationview Get/Find Header Layout
Android: Expand/Collapse Animation
How to Go Back to Previous Page If Back Button Is Pressed in Webview
Application Skeleton to Support Multiple Screens
How to Increase Heap Size of an Android Application
Call an Activity Method from a Fragment
Is the Way the Firebase Database Quickstart Handles Counts Secure
Getting the Screen Density Programmatically in Android
What APIs Are Used to Draw Over Other Apps (Like Facebook'S Chat Heads)
Drawing a Line/Path on Google Maps
Sending Images Using Http Post
Getting an Issue While Checking the Dynamically Generated Checkbox Through List View