Scroll view in Recycler View











up vote
0
down vote

favorite












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.










share|improve this question




















  • 1




    Can you explain why do you need a ScrollView? Like what do you try to achieve? If the only reason you need it is to place some views above and and make it scroll together you just need to use CoordinatorLayout with AppbarLayout. Way more elegant
    – Zach Bublil
    Nov 7 at 11:27












  • In case you are trying to achieve a list of elements with the first being an header I suggest you to keep only the RecyclerView and use different ViewTypes. Anyway you shouldn't use "wrap_content" as height for ScrollView and RecyclerView.
    – Jameido
    Nov 7 at 11:28












  • Thank you for the help..
    – itz Prateek
    Nov 7 at 12:02















up vote
0
down vote

favorite












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.










share|improve this question




















  • 1




    Can you explain why do you need a ScrollView? Like what do you try to achieve? If the only reason you need it is to place some views above and and make it scroll together you just need to use CoordinatorLayout with AppbarLayout. Way more elegant
    – Zach Bublil
    Nov 7 at 11:27












  • In case you are trying to achieve a list of elements with the first being an header I suggest you to keep only the RecyclerView and use different ViewTypes. Anyway you shouldn't use "wrap_content" as height for ScrollView and RecyclerView.
    – Jameido
    Nov 7 at 11:28












  • Thank you for the help..
    – itz Prateek
    Nov 7 at 12:02













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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.










share|improve this question















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.







android android-studio android-layout android-scrollview android-relativelayout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 21:03









Onik

10.9k103761




10.9k103761










asked Nov 7 at 11:23









itz Prateek

279




279








  • 1




    Can you explain why do you need a ScrollView? Like what do you try to achieve? If the only reason you need it is to place some views above and and make it scroll together you just need to use CoordinatorLayout with AppbarLayout. Way more elegant
    – Zach Bublil
    Nov 7 at 11:27












  • In case you are trying to achieve a list of elements with the first being an header I suggest you to keep only the RecyclerView and use different ViewTypes. Anyway you shouldn't use "wrap_content" as height for ScrollView and RecyclerView.
    – Jameido
    Nov 7 at 11:28












  • Thank you for the help..
    – itz Prateek
    Nov 7 at 12:02














  • 1




    Can you explain why do you need a ScrollView? Like what do you try to achieve? If the only reason you need it is to place some views above and and make it scroll together you just need to use CoordinatorLayout with AppbarLayout. Way more elegant
    – Zach Bublil
    Nov 7 at 11:27












  • In case you are trying to achieve a list of elements with the first being an header I suggest you to keep only the RecyclerView and use different ViewTypes. Anyway you shouldn't use "wrap_content" as height for ScrollView and RecyclerView.
    – Jameido
    Nov 7 at 11:28












  • Thank you for the help..
    – itz Prateek
    Nov 7 at 12:02








1




1




Can you explain why do you need a ScrollView? Like what do you try to achieve? If the only reason you need it is to place some views above and and make it scroll together you just need to use CoordinatorLayout with AppbarLayout. Way more elegant
– Zach Bublil
Nov 7 at 11:27






Can you explain why do you need a ScrollView? Like what do you try to achieve? If the only reason you need it is to place some views above and and make it scroll together you just need to use CoordinatorLayout with AppbarLayout. Way more elegant
– Zach Bublil
Nov 7 at 11:27














In case you are trying to achieve a list of elements with the first being an header I suggest you to keep only the RecyclerView and use different ViewTypes. Anyway you shouldn't use "wrap_content" as height for ScrollView and RecyclerView.
– Jameido
Nov 7 at 11:28






In case you are trying to achieve a list of elements with the first being an header I suggest you to keep only the RecyclerView and use different ViewTypes. Anyway you shouldn't use "wrap_content" as height for ScrollView and RecyclerView.
– Jameido
Nov 7 at 11:28














Thank you for the help..
– itz Prateek
Nov 7 at 12:02




Thank you for the help..
– itz Prateek
Nov 7 at 12:02












4 Answers
4






active

oldest

votes

















up vote
0
down vote



accepted










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






share|improve this answer





















  • Thank you for the help.
    – itz Prateek
    Nov 7 at 12:03










  • you are welcome
    – enesgonez
    Nov 7 at 12:45


















up vote
0
down vote













Just need to have Linear Layout (vertical) in ScrollView



   <?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="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<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>
</LinearLayout>
</ScrollView>





share|improve this answer





















  • Thank you so much for the help.
    – itz Prateek
    Nov 7 at 12:02


















up vote
0
down vote













Inside ScrollView layout there must have only one root layout. Notice that I have used LinearLayout as root layout. It could be also RelativeLayout



<?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">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<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>
</LinearLayout>

</ScrollView>





share|improve this answer




























    up vote
    0
    down vote













    You can use a NestedScrollView instead of your regular ScrollView like this



    <android.support.v4.widget.NestedScrollView
    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>

    </android.support.v4.widget.NestedScrollView>


    And then when initialising your RecyclerView just add these two lines:



    recyclerView.setHasFixedSize(true);
    recyclerView.setNestedScrollingEnabled(false);





    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53188523%2fscroll-view-in-recycler-view%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote



      accepted










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






      share|improve this answer





















      • Thank you for the help.
        – itz Prateek
        Nov 7 at 12:03










      • you are welcome
        – enesgonez
        Nov 7 at 12:45















      up vote
      0
      down vote



      accepted










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






      share|improve this answer





















      • Thank you for the help.
        – itz Prateek
        Nov 7 at 12:03










      • you are welcome
        – enesgonez
        Nov 7 at 12:45













      up vote
      0
      down vote



      accepted







      up vote
      0
      down vote



      accepted






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






      share|improve this answer












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







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 7 at 11:28









      enesgonez

      515




      515












      • Thank you for the help.
        – itz Prateek
        Nov 7 at 12:03










      • you are welcome
        – enesgonez
        Nov 7 at 12:45


















      • Thank you for the help.
        – itz Prateek
        Nov 7 at 12:03










      • you are welcome
        – enesgonez
        Nov 7 at 12:45
















      Thank you for the help.
      – itz Prateek
      Nov 7 at 12:03




      Thank you for the help.
      – itz Prateek
      Nov 7 at 12:03












      you are welcome
      – enesgonez
      Nov 7 at 12:45




      you are welcome
      – enesgonez
      Nov 7 at 12:45












      up vote
      0
      down vote













      Just need to have Linear Layout (vertical) in ScrollView



         <?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="match_parent">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      >
      <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>
      </LinearLayout>
      </ScrollView>





      share|improve this answer





















      • Thank you so much for the help.
        – itz Prateek
        Nov 7 at 12:02















      up vote
      0
      down vote













      Just need to have Linear Layout (vertical) in ScrollView



         <?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="match_parent">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      >
      <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>
      </LinearLayout>
      </ScrollView>





      share|improve this answer





















      • Thank you so much for the help.
        – itz Prateek
        Nov 7 at 12:02













      up vote
      0
      down vote










      up vote
      0
      down vote









      Just need to have Linear Layout (vertical) in ScrollView



         <?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="match_parent">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      >
      <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>
      </LinearLayout>
      </ScrollView>





      share|improve this answer












      Just need to have Linear Layout (vertical) in ScrollView



         <?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="match_parent">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      >
      <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>
      </LinearLayout>
      </ScrollView>






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 7 at 11:29









      Ali Ahmed

      9701114




      9701114












      • Thank you so much for the help.
        – itz Prateek
        Nov 7 at 12:02


















      • Thank you so much for the help.
        – itz Prateek
        Nov 7 at 12:02
















      Thank you so much for the help.
      – itz Prateek
      Nov 7 at 12:02




      Thank you so much for the help.
      – itz Prateek
      Nov 7 at 12:02










      up vote
      0
      down vote













      Inside ScrollView layout there must have only one root layout. Notice that I have used LinearLayout as root layout. It could be also RelativeLayout



      <?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">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      >
      <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>
      </LinearLayout>

      </ScrollView>





      share|improve this answer

























        up vote
        0
        down vote













        Inside ScrollView layout there must have only one root layout. Notice that I have used LinearLayout as root layout. It could be also RelativeLayout



        <?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">

        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
        <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>
        </LinearLayout>

        </ScrollView>





        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          Inside ScrollView layout there must have only one root layout. Notice that I have used LinearLayout as root layout. It could be also RelativeLayout



          <?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">

          <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          >
          <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>
          </LinearLayout>

          </ScrollView>





          share|improve this answer












          Inside ScrollView layout there must have only one root layout. Notice that I have used LinearLayout as root layout. It could be also RelativeLayout



          <?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">

          <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          >
          <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>
          </LinearLayout>

          </ScrollView>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 7 at 11:37









          Omar Hasan

          674




          674






















              up vote
              0
              down vote













              You can use a NestedScrollView instead of your regular ScrollView like this



              <android.support.v4.widget.NestedScrollView
              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>

              </android.support.v4.widget.NestedScrollView>


              And then when initialising your RecyclerView just add these two lines:



              recyclerView.setHasFixedSize(true);
              recyclerView.setNestedScrollingEnabled(false);





              share|improve this answer

























                up vote
                0
                down vote













                You can use a NestedScrollView instead of your regular ScrollView like this



                <android.support.v4.widget.NestedScrollView
                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>

                </android.support.v4.widget.NestedScrollView>


                And then when initialising your RecyclerView just add these two lines:



                recyclerView.setHasFixedSize(true);
                recyclerView.setNestedScrollingEnabled(false);





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  You can use a NestedScrollView instead of your regular ScrollView like this



                  <android.support.v4.widget.NestedScrollView
                  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>

                  </android.support.v4.widget.NestedScrollView>


                  And then when initialising your RecyclerView just add these two lines:



                  recyclerView.setHasFixedSize(true);
                  recyclerView.setNestedScrollingEnabled(false);





                  share|improve this answer












                  You can use a NestedScrollView instead of your regular ScrollView like this



                  <android.support.v4.widget.NestedScrollView
                  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>

                  </android.support.v4.widget.NestedScrollView>


                  And then when initialising your RecyclerView just add these two lines:



                  recyclerView.setHasFixedSize(true);
                  recyclerView.setNestedScrollingEnabled(false);






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 7 at 11:46









                  Ezzy

                  6122621




                  6122621






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53188523%2fscroll-view-in-recycler-view%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      Tangent Lines Diagram Along Smooth Curve

                      Yusuf al-Mu'taman ibn Hud

                      Zucchini