1

У меня есть макет, как показано ниже: отключить сенсорные события для RecyclerView внутри NestedScrollV

<android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/detail_backdrop_height" 
     android:fitsSystemWindows="true" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:elevation="0dp"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:elevation="0dp" 
      app:expandedTitleMarginEnd="64dp" 
      app:expandedTitleMarginStart="48dp" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:fitsSystemWindows="true" 
       app:layout_collapseMode="parallax"> 

       <ImageView 
        android:id="@+id/backdrop" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:fitsSystemWindows="true" 
        android:scaleType="centerCrop" 
        android:src="@drawable/devito" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_above="@+id/rating" 
        android:fitsSystemWindows="true" 
        android:padding="8dp" 
        android:text="Danny DeVitto" 
        android:textSize="24sp" /> 

      </RelativeLayout> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:elevation="0dp" 
       app:layout_collapseMode="pin" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

     </android.support.design.widget.CollapsingToolbarLayout> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:id="@+id/scrollView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Info" 
       android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="@dimen/card_margin"> 

       <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <android.support.v7.widget.RecyclerView 
        android:id="@+id/someList" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" /> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="@string/cheese_ipsum" /> 

       </LinearLayout> 

      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="@dimen/card_margin" 
       android:layout_marginLeft="@dimen/card_margin" 
       android:layout_marginRight="@dimen/card_margin"> 

       <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Friends" 
         android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

        <android.support.v7.widget.RecyclerView 
        android:id="@+id/anotherList" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" /> 

       </LinearLayout> 

      </android.support.v7.widget.CardView> 

     </LinearLayout> 


    </android.support.v4.widget.NestedScrollView> 


</android.support.design.widget.CoordinatorLayout> 

Где идея находится панель разрушается при прокрутке вверх (вниз?). Но есть проблема, когда происходит событие касания. Если прокрутка инициирована для любого элемента, кроме RecyclerView, все работает как шарм. Но если при повторном просмотре инициируется прокрутка, NestedScrollView начинает прокрутку без смены панели или расширения. RecyclerViews использует собственный менеджер макетов, который обертывает его содержимое (каждый RecyclerView имеет несколько элементов). Итак, вот вопрос. Как сообщить RecyclerView, чтобы он не вмешивался в процесс свертывания/расширения NestedScrollView?

+0

Если я помню ... вам может потребоваться ctually создайте свой собственный адаптер recyclerview и перестаньте обнаруживать прокрутку – lawonga

ответ

1

я была такая же проблема, но с NestedScrollView я использовал

android:nestedScrollingEnabled="false" 

и проблема исчезла, пожалуйста, попробуйте добавить это и скажите мне, если он работает

удачи

+0

. Я думаю, это может сработать, но я пошел другим путем. Я заменил свой recyclerview необходимым количеством текстовых просмотров ..)) Я собираюсь проверить это как ответ. – Kuanysh

0

Попробуйте следующее:

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