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.
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
Below one is the screenshot after scrolled.
I have 3 Layouts in constarintLayout Blue is the top layout, Yellow is the middle Layout (Recycler View), Green is the End Layout.
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
Below one is the screenshot after scrolled.