Search code examples
androidandroid-studioandroid-layoutandroid-scrollviewandroid-relativelayout

Scroll view in Recycler View


How can i add scroll view in the xml file with having Relative layout, Recycler view, TextView, Image View. Below is the respective xml code :

Please go through the below code.

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".StoryList">
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

<ImageView
    android:id="@+id/skandaimagestory"
    android:src="@drawable/pictureskanda"
    android:layout_width="match_parent"
    android:layout_height="130dp" />
<TextView
    android:id="@+id/Heading"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/skandaimagestory"
    android:gravity="center"
    android:padding="17dp"
    android:text="SURVIVORS TALES"
    android:textSize="20dp"
    android:textStyle="bold" />

<LinearLayout
    android:layout_below="@+id/Heading"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.RecyclerView
        android:background="#f6facf"
        android:padding="10dp"
        android:id="@+id/story_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </android.support.v7.widget.RecyclerView>

</LinearLayout>

</ScrollView>

Thank you in advance.


Solution

  • You can use android.support.v4.widget.NestedScrollView