2017-03-01 77 views
0

工作,我在标签布局使用NestedScrollView,当我在NestedScrollView实施RecyclerView会出现两个问题:RecyclerView不NestedScrollView

  1. 工具栏没有隐瞒。
  2. RecyclerView不能平滑滚动。

这里是我的代码:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:fillViewport="true" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:background="#fff" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.RecyclerView 
      android:layout_below="@+id/toolbar" 
      android:id="@+id/recyclerView" 
      android:background="#fafafa" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" /> 

     <ProgressBar 
      android:id="@+id/progressBar1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" /> 

    </RelativeLayout> 

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

你有NestedScrollView中的工具栏,因为根据你的代码,你用android添加你的RecyclerView:layout_below =“@ + id/toolbar” –

回答

0

使用recylerView.setNestedScrollingEnabled(false);,使您的滚动顺畅。

+0

不,它不工作。 –

0

为视图创建单独的布局文件并尝试。并将其包含到列表视图中。

<LinuearLayout ..> 
    <include layout="@layout/cv1"/> 
    <include layout="@layout/rv1"/> 
    <include layout="@layout/rv2"/> 
    <include layout="@layout/rv3"/> 
</LinearLayout> 

这只是给你的一个线索。过去我早就解决过类似的问题。请尝试尝试这个线索。

相关问题