2016-05-13 52 views
0

我在ScrollView里面创建RecyclerView和ListView,并且我得到滚动问题。滚动是跳动(无法获得平滑滚动),我知道它与ScrollView中的RecyclerView有关的问题,因为布局滚动时没有任何问题,直到ListView存在为止,但一旦RecyclerView项目进入布局,它开始猛拉(只用手指滚动,当手指脱落时没有正确的滚动)。下面是在XML当ScrollView里面的RecyclerView时的布局跳转

沿同一轴线滚动
<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 

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


     <ListView 
      android:id="@+id/lv_home_dropdown" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:divider="@color/colorWhite" 
      android:dividerHeight="0.5dp" 
      android:visibility="gone"/> 

     <android.support.v7.widget.RecyclerView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/recycleView" 
      android:background="@color/colorWhite"> 

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

    </LinearLayout> 
</ScrollView> 
+0

制作一个高度为wrap_content的ListView会导致各种问题。将ListView从ScrollView中移出,你的问题就会消失。 – dharms

+0

@dharms:我需要在ListView中的内容之后跟踪RecyclerView中的数据。如果我将ListView设置为match_parent,那将是一个问题! –

+0

您可以将该视图添加为ListView的页脚。 – dharms

回答

1
  1. 嵌套视图代码一直 问题在Android上。最近谷歌已经添加了嵌套滚动 的支持。为了在较旧的平台级别上拥有此功能,您应该使用NestedScrollViewRecyclerView等支持库中的视图。

  2. ListView不能与wrap_content一起使用。如果您拥有 RecyclerView支持库的最新版本,您可以使用RecyclerView做 。此外,您已经在一个地方使用RecyclerView,您不妨独占使用它们。

  3. ListView并非真的是一个“下拉”。也许你应该考虑改为Spinner

0

我终于有了它。 只需添加以下代码行,你所在班级您呼叫的RecyclerView

mRecyclerView = (RecyclerView)tmpView.findViewById(R.id.recycleView); 
mRecyclerView.setNestedScrollingEnabled(false); 

这对我的作品!

相关问题