2

As described in below image. I have one layout above the recycler view and one below. both tags are the linear layout. I face two problems.

  1. because the recycler view has inner scroll therefore if items in recycler view increase, the first linear layout stays at the same place but I am expecting it to scroll up while scrolling items.

  2. When items increase in recycler view the second layout get disappear. how to make the layout scroll when recycler view reaches its last item.

Tried android:nestedScrollingEnabled="false" it disables the scroll effect but shows only a few items in the recycler view.

Require solutions: if somehow I can make the recycler views items static and display all the available contents. so the parent layout decides whether scroll or not. if size increase it will scroll otherwise not.

enter image description here

Omeed Totakhel
  • 487
  • 1
  • 10
  • 32
  • You need add the first and second layout as items in your RecyclerView, and use different view types – badoualy Oct 04 '17 at 15:09

2 Answers2

0

You can add both LinearLayouts to the RecyclerView as header and footer views. The top answer in this question should give you an idea how to make this: RecyclerView header and footer

0

If your two LinearLayout have fixed size, you can fix them inside a RelativeLayout and then insert your RecyclerView "in between".

<RelativeLayout>
  <LinearLayout alignParentTop="true" height="100dp" id="@+id/topLayout"/>
  <LinearLayout alignParentBottom="true" height="100dp" id="@+id/bottomLayout"/>
  <RecyclerView height="match_parent" above="@id/bottomLayout" below="@id/topLayout"/>
</RelativeLayout>

Alternatively, if your top container is a LinearLayout, you can play with weights (1 for top LinearLayout, 1 for bottom LinearLayout, 3 for RecyclerView)

<LinearLayout orientation="vertical">
  <LinearLayout height="0dp" weight="1"/>
  <RecyclerView height="0dp" weight="3"/>
  <LinearLayout height="0dp" weight="1"/>
</LinearLayout>
NSimon
  • 5,212
  • 2
  • 22
  • 36