Reputation: 1404
I have a RecyclerView with wrap_content, the height works well when the recyclerview has some items, but when RecyclerView fills the parent, the RecyclerView starts to scroll.
this is the layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/white"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".activity.RegistroVentaActivity$BusquedaFragment">
<RelativeLayout
android:id="@+id/rlManualSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- some items kind of header -->
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlResults"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/palette_flat_asphalt_3"
android:visibility="visible">
<TextView
android:id="@+id/tvResultsHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/palette_flat_asphalt_3"
android:padding="10dp"
android:text="@string/search_results_hint"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/white" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rvProductosCoinsidencias"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvResultsHint"
android:background="@android:color/white"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:clipToPadding="false"
android:columnWidth="@dimen/rv_productos_column_width"
android:padding="@dimen/rv_item_padding"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
Note: the layout is a fragment (ViewPager), parent is a CoordinatorLayout.
so the "header" stays always in screen and RecyclerView starts to scroll i need to scroll everything together when recyclerView reach height parent.
how can i to do it?
im ussing
i have tried
nothing seems work.
Upvotes: 0
Views: 848
Reputation: 1536
That is the default behaviour of RecyclerView. There are two ways you can do to achieve your goal:
Make the Header the first item in the List used by the RecyclerView.
Use a vertical LinearLayout inside of a ScrollView, where the header is the first child view of the LinearLayout and other items are below the Header.
Upvotes: 2