I want to Scroll ReyclerView
inside a Fixed
height/region.
Sample XML to demonstrate the use case
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ele_parent_ll"
android:layout_width="match_parent"
android:orientation="vertical"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:id="@+id/election_parent_sv"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/sample_id"
android:background="@color/white"
android:fitsSystemWindows="true">
<ImageView
android:contentDescription="@string/btn_youtube"
android:layout_width="match_parent"
android:layout_height="115dp"
android:id="@+id/election_banner"
android:background="@drawable/some_drawable"
android:adjustViewBounds="true"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mid_parent"
android:layout_marginLeft="@dimen/view_margin_10"
android:layout_marginRight="@dimen/view_margin_10"
android:layout_marginTop="@dimen/view_margin_10"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shaded_purple_new_local"
android:text="Layout heading"
android:textColor="@color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Choose one"
android:textColor="@color/icon_yellow"
android:textSize="13sp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/candidate_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/view_margin_10"
android:layout_marginLeft="@dimen/view_margin_10"
android:layout_weight=".5"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!--Sample Layout to make the screen scrollable for the example-->
<RelativeLayout
android:id="@+id/samp_RL"
android:layout_width="match_parent"
android:layout_height="200dp">
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
In this scenario, the RecyclerView
is taking it's required space and list is pretty much long so the total length of the scrollable area has gone long so probability of seeing elements below RCV has decreased.
To solve this I want to scroll RecyclerView
inside a fixed area so that If the user is not interested in that he can easily look up to the other Elements present below the RecyclerView
- When user scrolls within the region of RCV the RCV should scroll.
- When the user scrolls outside the RCV the whole Layout should scroll
Image made at draw.io
What I have tried:
- Making the height of RecyclerView constant: It is Jammed and is not scrolling at all.
- Making Recyclerview Fixed Height and Scrollable : It's also the same. It is jammed and is not scrolling at all.
- Scrollable NestedScrollViews inside RecyclerView: Tried this but could not establish a connection to my current situation.
Please tell what I am missing here.