Arsen Tatraev
Arsen Tatraev

Reputation: 788

The view above recyclerview is skipped

I have CardView above RecycleView, but when Page is loaded RecyclerView is on the top and CardView is skipped. Why can this happen?

<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ProgressBar
            android:id="@+id/homeProgress"
            android:layout_width="100dp"
            android:layout_height="100dp"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            android:progressTint="@color/colorText"
            android:visibility="visible"/>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/homeMainLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorBackground"
            android:padding="10dp"
            android:visibility="gone">

            <androidx.cardview.widget.CardView
                android:id="@+id/firstPlace"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/colorCardView"
                app:cardCornerRadius="10dp"
                android:padding="10dp"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">


                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:padding="10dp">

                        <TextView
                            android:id="@+id/firstPlaceName"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textSize="30sp"
                            android:textColor="@color/colorText"/>

                        <TextView
                            android:id="@+id/firstPlaceCount"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textSize="15sp"
                            android:textColor="@color/colorText"/>

                    </LinearLayout>

                    <ImageView
                        android:id="@+id/firstPlaceImage"
                        android:layout_width="100dp"
                        android:layout_height="100dp"
                        android:layout_alignParentEnd="true"/>


                </RelativeLayout>
            </androidx.cardview.widget.CardView>

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/artistsWithImagesRecycler"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintTop_toBottomOf="@+id/firstPlace"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                android:overScrollMode="never"
                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager">

            </androidx.recyclerview.widget.RecyclerView>

        </androidx.constraintlayout.widget.ConstraintLayout>


    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

Upvotes: 0

Views: 71

Answers (3)

Prakash Reddy
Prakash Reddy

Reputation: 1002

Add weight to cardview and recyclerview or change constraint layout to relative layout, remove below lines in recyclerview

app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent

Upvotes: 0

Reham Alatris
Reham Alatris

Reputation: 435

align your recyler view to top to bottom of card view

Upvotes: 1

DeadStar
DeadStar

Reputation: 109

You have set the ConstraintLayout with id homeMainLayout to be "gone". Remove the attribute android:visibility="gone" from it and the card view will be shown as you expect.

Upvotes: 0

Related Questions