Reputation: 1509
I'm trying to put a RecyclerView
, inside a ScrollView
. But the ScrollView
doesn't scrolls and the RecyclerView
does but I don't want it to... What can I do?
I tried with this class https://stackoverflow.com/a/30222721/4864104 and in fact the RecyclerView
doesn't scroll anymore, but neither does the ScrollView
.
Any help to make the ScrollView
work even with the disabled RecyclerView
? Thanks in advance.
This is my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="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="jahirfiquitiva.projects.activities.DeveloperActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<ScrollView
android:id="@+id/osv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:fillViewport="true"
android:gravity="center"
android:overScrollMode="never">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<ImageView
android:id="@+id/photoJahir"
android:layout_width="144dp"
android:layout_height="144dp"
android:layout_gravity="center"
android:gravity="center" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.2"
android:paddingBottom="@dimen/lists_padding"
android:paddingTop="@dimen/lists_padding"
android:text="@string/developer_bio"
android:textSize="@dimen/abc_text_size_subtitle_material_toolbar" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dividers_about_section"
android:alpha="0.3"
android:background="@color/primary" />
<RecyclerView
android:id="@+id/buttonsGrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/lists_padding"
android:paddingTop="@dimen/lists_padding" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dividers_about_section"
android:alpha="0.3"
android:background="@color/primary" />
<View
android:layout_width="match_parent"
android:layout_height="72dp" />
</LinearLayout>
</ScrollView>
Upvotes: 3
Views: 11499
Reputation: 5804
You could easily achieve it by changing your scroll view into a NestedScrollView and setting recyclerView.setNestedScrollingEnabled(false)
Has the highest performance and No need to override the layout manager.
Upvotes: 11
Reputation: 1378
it not as simple as you think. when you use tow scrollble element inside each other you are in hot water! you should calculate the Recycler item height and then find the whole recycler height. look at below link, I explain completely this problem.
Use RecyclerView indie ScrollView with flexible recycler item height
I hope it help you
Upvotes: 0
Reputation: 1088
I think you just need to wrap recyclerView so that other views can be visible. Just use this library so that you can adjust recycler view height coz linearLayoutManager as per now matches height to match parent. https://github.com/serso/android-linear-layout-manager
Upvotes: 0