Teja
Teja

Reputation: 967

TextViews below recyclerview are not displaying

The TextViews Below RecyclerView are not displaying.The whole screen is occupied by RecyclerView.If i use Nestedscrollview only TextViews are displaying but not RecyclerView.Please Anyone provide solution for this

 <LinearLayout
            android:id="@+id/wrapper"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recycler_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scrollbars="vertical" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/wrapper"
            android:orientation="vertical">


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hello" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hello" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hello" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hello" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hello" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hello" />


        </LinearLayout>

    </RelativeLayout>

Upvotes: 3

Views: 3779

Answers (2)

Houssin Boulla
Houssin Boulla

Reputation: 2859

You can use NestedScrollView if you want to display RecycleView with other Views like (TextView, Button another recycleView ....) like this example:

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"        
        android:layout_marginTop="2dp"
        android:layout_marginStart="2dp"
        android:layout_marginEnd="2dp">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_product"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:text="@string/trending"
            android:supportsRtl="true"
            android:textColor="@color/colorPrimary"
            android:textSize="14sp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_stores"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</androidx.core.widget.NestedScrollView>

Upvotes: 5

Ashish Kudale
Ashish Kudale

Reputation: 1260

this will divide your screen in two parts first half will be covered by recyclerview and another by textviews.

try this.

<LinearLayout
    android:id="@+id/wrapper"
    android:orientation="vertical"
    android:layout_weight="1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical" />

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_weight="1"
    android:layout_height="match_parent"
    android:layout_below="@+id/wrapper"
    android:orientation="vertical">


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello" />


</LinearLayout>

Upvotes: 3

Related Questions