0

I am trying to put RecyclerView inside ScrollView, I Have layout above the recycler view, so I want to scroll both layout and recycler while scrolling.

In My main Layout I have two sub Layout , and one of the have recyclerView and another one Have an Image .Both layout inside a scrollView. When I scrolling up in the layout , I want to scroll both

I know the issue that we cant put two scroll view in one layout. Am searching is there any logic that we can scroll both layout and recycler View

Layout.xml

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/backgorund"
android:weightSum="1">

 <ScrollView
    android:id="@+id/scrollView1"

    android:layout_width="match_parent"
    android:fillViewport="true"
android:layout_height="match_parent" >

<LinearLayout

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1">
<LinearLayout
    android:id="@+id/layout_top_balance"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight=".25">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/txt_balance"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:textSize="35dp"
            android:textColor="@color/black"
            android:text="$60 USD"/>
        <TextView
            android:layout_below="@+id/txt_balance"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:textSize="20dp"
            android:textColor="#828282"
            android:text="Account Balance"/>
    </RelativeLayout>
</LinearLayout>
<LinearLayout
    android:id="@+id/layout_feeds"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:paddingLeft="16dp"
    android:paddingBottom="5dp"
    android:layout_weight=".75">

    <view
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        class="android.support.v7.widget.RecyclerView"
        android:id="@+id/recycler_view"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"/>
</LinearLayout>
    </LinearLayout>
</ScrollView>

Cam any one please help for solving this issue:)

Binil Surendran
  • 2,524
  • 6
  • 35
  • 58
  • 4
    `RecyclerView` it self a `ScrollView` – IntelliJ Amiya Jan 04 '16 at 07:11
  • In My main Layout I have two sub Layout , and one of the have recyclerView and another one Have an Image .Both layout inside a scrollView. When I scrolling up in the layout , I want to scroll both @IntelliJ Amiya – Binil Surendran Jan 04 '16 at 07:14
  • http://stackoverflow.com/questions/27083091/recyclerview-inside-scrollview-is-not-working – IntelliJ Amiya Jan 04 '16 at 07:16
  • @BinilS you can add those part as a header of RecyclerView – Kaushik Jan 04 '16 at 07:16
  • or you can customize the layout manager you attaching to recyclerview and use [`NestedScrollView`](http://developer.android.com/intl/es/reference/android/support/v4/widget/NestedScrollView.html) – Kaushik Jan 04 '16 at 07:19

2 Answers2

1

It is not recommended to scroll inside scroll in android. Recycler view is itself a scroll. Seems you want a scrollable portion above a list "layout_top_balance". Add this view as header of recycler view and remove scrollview. This will solve your problem.

Qandil Tariq
  • 539
  • 1
  • 3
  • 15
1

You can use this recycle view lib if you want to add header

RecyclerViewHeader Example 1

RecyclerViewHeader Example 2

Mohit Suthar
  • 8,725
  • 10
  • 37
  • 67