5

'da birden çok RecyclerViews ile işlem yapma İki RecyclerViews içeren bir düzen oluşturdum. Biri yatay olarak kayarken diğeri dikey olarak kaydırılır. Her bir RecyclerView içinde doğru bir şekilde ilerleyebilirim fakat bir bütün olarak sayfa kaydırma yapmaz, yani üstteki RecyclerView her zaman üstte kalır ve altta her ikisi de olduğu gibi altta durur. - Benim ilk öneri o denemek olacaktır sürümü 22.2.0 iç içe geçmiş kaydırma içinDüzeni

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

     <EditText 
      android:id="@+id/search" 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:hint="Search Dramas" 
      android:textSize="16sp" 
      android:paddingLeft="10dp" 
      android:gravity="center" 
      android:textColor="@color/dark_grey" 
      android:textColorHint="@color/dark_grey" 
      android:background="@drawable/border_bottom"/> 


     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/border_bottom_background_black" 
      android:textColor="@color/white" 
      android:padding="10dp" 
      android:text="Most Watched"/> 

     <!-- A RecyclerView to display horizontal list --> 
     <android.support.v7.widget.RecyclerView 
      android:id="@+id/featured" 
      android:scrollbars="none" 
      android:layout_width="fill_parent" 
      android:layout_height="240dp" 
      android:paddingLeft="0dp" 
      android:paddingRight="15dp" 
      android:paddingTop="15dp" 
      android:paddingBottom="25dp" 
      android:background="@color/black"/> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/border_bottom_backgroundless" 
      android:textColor="@color/dark_grey" 
      android:padding="10dp" 
      android:text="All Dramas"/> 

     <!-- A RecyclerView to display vertical list --> 
     <android.support.v7.widget.RecyclerView 
      android:id="@+id/pick_item" 
      android:scrollbars="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="match_parent"/> 


</LinearLayout> 

How activity looks

cevap

6

ScrollView içine her şeyi koyarak ve sonra manuel/programmatically dikey RecyclerView yüksekliğini ayarlayarak sorunu çözebildi.

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/scrollView"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

      <EditText 
       android:id="@+id/search" 
       android:layout_width="fill_parent" 
       android:layout_height="50dp" 
       android:hint="Search Dramas" 
       android:textSize="16sp" 
       android:paddingLeft="10dp" 
       android:gravity="center" 
       android:textColor="@color/dark_grey" 
       android:textColorHint="@color/dark_grey" 
       android:background="@drawable/border_bottom"/> 


      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@drawable/border_bottom_background_black" 
       android:textColor="@color/white" 
       android:padding="10dp" 
       android:text="Most Watched"/> 

      <!-- A RecyclerView to display horizontal list --> 
      <android.support.v7.widget.RecyclerView 
       android:id="@+id/featured" 
       android:scrollbars="none" 
       android:layout_width="fill_parent" 
       android:layout_height="240dp" 
       android:paddingLeft="0dp" 
       android:paddingRight="15dp" 
       android:paddingTop="15dp" 
       android:paddingBottom="25dp" 
       android:background="@color/black"/> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@drawable/border_bottom_backgroundless" 
       android:textColor="@color/dark_grey" 
       android:padding="10dp" 
       android:text="All Dramas"/> 

      <!-- A RecyclerView to display list --> 
      <android.support.v7.widget.RecyclerView 
       android:id="@+id/pick_item" 
       android:paddingBottom="20dp" 
       android:scrollbars="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="match_parent" 
       android:minHeight="840dp"/> 


    </LinearLayout> 
</ScrollView> 

programlı RecyclerView yüksekliğini ayarlama:

Bir düzeninde ve bir kaydırma görünümünde üç recycler görünümü kullanılan
LinearLayout.LayoutParams params = new  
    LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 
    ViewGroup.LayoutParams.WRAP_CONTENT); 
// calculate height of RecyclerView based on child count 
params.height=1150; 
// set height of RecyclerView 
recyclerView.setLayoutParams(params); 
+0

RecycleVew optimizasyonunu kaybediyor musunuz, değil mi? Başka bir deyişle, RecycleView, görüşleri geri dönüştürmez. –

3

RecyclerView sadece kazanmıştır (hala sınırlı) desteği: Aşağıdaki

benim xml düzenidir. Tamamen iç içe kaydırma destekler

tek görünüm NestedScrollView ve (biraz 22.2.0 iyileşme) Destek v4 sürümü 22.1.0 eklendi (bunu hem NestedScrollingChild ve NestedScrollingParent uygular belirterek da bunu görebilirsiniz) 'dir. Dikey RecyclerView öğesinin en üstteki öğesi olarak yalnızca tek bir yatay RecyclerView varsa, bunun yerine LinearLayoutLinearLayout yatay RecyclerView dikey ve RecyclerView dikey konumunuzu içeren bir NestedScrollView ile değiştirebilirsiniz.

+0

. geri dönüştürücüm, 2 geri dönüşümcü görünümünde öğeleri kaydırılarak görüntüleniyor. ve tüm öğeleri kaydırmadan göstermek istedim. ama NestedScrollView ile başarı elde etti. teşekkürler –