如何处理Scrollview慢Android

时间:2017-06-15 08:55:41

标签: android scrollview nestedscrollview

我在一个布局中使用了两个recyclerview,如果我想两个recylerview都可以滚动,我添加嵌套Scrollview。

也许是这样的:

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/NestedScrollView"
    android:layout_below="@+id/toolbar">

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

   <RelativeLayout
        android:id="@+id/xx"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/arrayListUser"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:divider="@color/white">


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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginLeft="3dp"
            android:layout_marginRight="3dp"
            android:background="@color/line"/>

    </RelativeLayout>
    <RelativeLayout

        android:layout_width="wrap_content"
        android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/arrayList"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:divider="@color/white">


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

    </RelativeLayout>

</LinearLayout>

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

在一个Nestedscrollview中的两个Recylerview进行慢速滚动。那么,如何处理以使其快速?

1 个答案:

答案 0 :(得分:2)

setNestedScrollingEnabled设为false

    mRecyclerView.setNestedScrollingEnabled(false);

以及布局

    <android.support.v7.widget.RecyclerView
        ...
        android:nestedScrollingEnabled="false"/>

启用或禁用此视图的嵌套滚动。