2017-08-28 108 views
3
<android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true" 
     > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="15dp" 
      android:background="#e7e7e8" 
      android:orientation="vertical" 
      tools:ignore="RtlHardcoded"> 

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

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


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


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


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


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

       /> 

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

應用平滑垂直滾動這是我的代碼,我到裏面NestedScrollView 6 RecyclerView但是當我滾動垂直平滑滾動不工作任何一個可以請建議我如何在NestedScrollView應用平滑滾動如何NestedScrollView在android系統

回答

2

添加recyclerviews裏面NestedScrollView不是很好的做法。儘可能避免這種情況。
這裏有一些替代品...

  • 使用的物品爲recyclerview項目 - 種多型 recyclerview
  • 使用recyclerview水平方向顯示 內容很好。
+0

我明白這一點,但我的要求是這樣,我們必須採取多種recylerview – Adevelopment

+1

這是正確的答案 –

+0

@Adevelopment你必須去替代品。這是代表性差的跡象。 – Wizard

0

試試以下代碼,將此行添加到您的RecyclerView

android:fadeScrollbars="false" 
    android:nestedScrollingEnabled="true" 

(OR)

使用下面的代碼編程。

mRecyclerView.setOnTouchListener(new View.OnTouchListener() { 
      // Setting on Touch Listener for handling the touch inside ScrollView 
      @Override 
      public boolean onTouch(View v, MotionEvent event) { 
       // Disallow the touch request for parent scroll on touch of child view 
       NestedScrolling.setScrollContainer(false); 
       v.getParent().requestDisallowInterceptTouchEvent(true); 
       return false; 
      } 
     }); 

我希望這可以幫助你。

0

NestedScrollView insinde滾動型。

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
0

如果您正在使用RecyclerView內NestedScrollView然後用mRecyclerView.setNestedScrollingEnabled(false);

如果萬一它不RecyclerView工作順利滾動內NestedScrollView或僅NestedScrollView然後確保你的compileSdkVersion匹配您當前使用的庫版本。

例如。在所有的build.gradle文件compileSdkVersion 25 buildToolsVersion '25 .0.3'

然後您的支持appcompact庫版本

compile "com.android.support:appcompat-v7:25.3.1"

,如果你不能找到那麼你的錯配庫版本在Android上運行以下命令工作室終端。它應該根據compileSdkVersion獲取當前使用的庫版本和最新的庫版本。

./gradlew -q dependencies app:dependencies --configuration compile