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.
android android-studio android-layout android-scrollview android-relativelayout
add a comment |
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.
android android-studio android-layout android-scrollview android-relativelayout
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
add a comment |
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.
android android-studio android-layout android-scrollview android-relativelayout
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
android android-studio android-layout android-scrollview android-relativelayout
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
add a comment |
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
add a comment |
4 Answers
4
active
oldest
votes
up vote
0
down vote
accepted
You can use android.support.v4.widget.NestedScrollView
Thank you for the help.
– itz Prateek
Nov 7 at 12:03
you are welcome
– enesgonez
Nov 7 at 12:45
add a comment |
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>
Thank you so much for the help.
– itz Prateek
Nov 7 at 12:02
add a comment |
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>
add a comment |
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);
add a comment |
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
Thank you for the help.
– itz Prateek
Nov 7 at 12:03
you are welcome
– enesgonez
Nov 7 at 12:45
add a comment |
up vote
0
down vote
accepted
You can use android.support.v4.widget.NestedScrollView
Thank you for the help.
– itz Prateek
Nov 7 at 12:03
you are welcome
– enesgonez
Nov 7 at 12:45
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You can use android.support.v4.widget.NestedScrollView
You can use android.support.v4.widget.NestedScrollView
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
add a comment |
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
add a comment |
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>
Thank you so much for the help.
– itz Prateek
Nov 7 at 12:02
add a comment |
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>
Thank you so much for the help.
– itz Prateek
Nov 7 at 12:02
add a comment |
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>
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>
answered Nov 7 at 11:29
Ali Ahmed
9701114
9701114
Thank you so much for the help.
– itz Prateek
Nov 7 at 12:02
add a comment |
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
add a comment |
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>
add a comment |
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>
add a comment |
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>
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>
answered Nov 7 at 11:37
Omar Hasan
674
674
add a comment |
add a comment |
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);
add a comment |
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);
add a comment |
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);
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);
answered Nov 7 at 11:46
Ezzy
6122621
6122621
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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