2016-06-24 2 views
0

У меня есть RecyclerView с wrap_content, высота работает хорошо, когда recyclerview имеет некоторые элементы, но когда RecyclerView заполняет родителя, RecyclerView начинает прокручиваться.Прокрутки RecyclerView после заполнения родительского контейнера

это расположение:

<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> 

Примечание: макет представляет собой фрагмент (ViewPager), родитель является CoordinatorLayout.

так «заголовок» всегда остается в экране и RecyclerView начинает прокручивать мне нужно прокрутить все вместе, когда recyclerView достигают высоты родителя.

как я могу это сделать?

им Ussing

  • com.android.support:design:24.0.0
  • com.android.support:support-v4:24.0.0

я попробовал

  • nestedScrollEnabled true, false
  • hasFixedSize true, false
  • autoMeasureEnabled истинный, ложный
  • LinearLayoutManager
  • GridLayoutManger
  • CustomsLayoutManater (от поиска в Google)
  • Старых официальных версий recyclerview

ничего не кажется, работа.

ответ

1

Это поведение по умолчанию для RecyclerView. Есть два способа вы можете сделать, чтобы достичь своей цели:

  1. сделать заголовок первого элемента в списке, используемой RecyclerView.

  2. Используйте вертикальный LinearLayout внутри ScrollView, где заголовок является первым детским представлением LinearLayout, а другие элементы находятся под заголовком.

+0

я могу прокручивать содержимое вместе, как я просил, но скроллинг не свернуть CollapsingToolbarLayout, что мне нужно конфиг в ScrollView для того, чтобы вызвать Collapse Эффект CollapsingToolbarLayout? –

+0

NestedScrollView (вместо ScrollView) выполнил работу CollapseingToolbarLayout, большое спасибо: D –

Смежные вопросы