• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps RecyclerView in ConstraintLayout OnScroll Issue

shubham1835

Lurker
My RecyclerView in constraint layout is not working as expected. RecyclerView Item is getting scrolled to top and alignment of items are getting changed.
I have 3 Layouts in constarintLayout Blue is the top layout, Yellow is the middle Layout (Recycler View), Green is the End Layout.

upload_2021-2-22_2-1-11.png

Above one is the layout design below is the xml code.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
android:id="@+id/startLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/recyclerViewFrameLayout"
app:layout_constraintLeft_toRightOf="parent"
android:background="#372CD3"
app:layout_constraintRight_toLeftOf="parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</FrameLayout>

<FrameLayout
android:id="@+id/recyclerViewFrameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="#fff123"
app:layout_constraintTop_toBottomOf="@+id/startLayout">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>

<FrameLayout
android:id="@+id/endLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="#abc123"
app:layout_constraintStart_toStartOf="parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Below one is the app screenshot
upload_2021-2-22_2-3-48.png


Below one is the screenshot after scrolled.
upload_2021-2-22_2-4-49.png
 
Welcome to AndroidForums.com. :) To make your code more readable and make it easier for the folks that can help, well, help, you should use code tags.

Code Tag Usage:
[code]Line 1
Line 2
Line 3
Maintains white space
Doesn't turn :) into emoji
etc...
[/code]
Code:
Line 1
Line 2
Line 3
Maintains white space
Doesn't turn :) into emoji
etc...

Good luck!! :)
 
Back
Top Bottom