【问题标题】:recyclerview fast scroll not works after touch event触摸事件后recyclerview快速滚动不起作用
【发布时间】:2017-07-02 17:06:23
【问题描述】:

我在nestedscrollview 中有一个recyclerview,我可以通过触摸事件滚动recyclerview。但我的问题是当我快速滚动recyclerview时,拿起我的手指后,滚动停止。但我想要的是,它会根据我手指的速度滑动。

这是我的布局: item_container_list.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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"
    android:paddingLeft="10dp"
    android:paddingRight="10dp">


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

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

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

</RelativeLayout>

我用一个片段来膨胀它

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.item_container_list,container,false);

    recyclerView = (RecyclerView)view.findViewById(R.id.container_list);

    layoutManager = new LinearLayoutManager(this.getContext(), LinearLayoutManager.VERTICAL, false);

    recyclerView.setLayoutManager(layoutManager);
    //recyclerView.addItemDecoration(new SimpleDividerItemDecoration(this.getContext()));

    return view;
}

这里是视频:https://youtu.be/OCu7Nobvblc

【问题讨论】:

    标签: android android-recyclerview nestedscrollview


    【解决方案1】:

    将此添加到您的 onCreateView 方法后尝试:-

    recyclerView.setNestedScrollingEnabled(false);
    

    【讨论】:

    • 噗,我想哭 :-) 谢谢。
    • 是的,我在互联网上研究了两天。我试过了,但现在可以了。 4分钟后,我将能够接受您的回答。非常感谢。
    • 太棒了!我很高兴它有效。并感谢您的接受。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多