Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在活动中滚动多个回收器视图。(如何使其平滑)_Java_Android_Android Recyclerview_Scrollview - Fatal编程技术网

Java 在活动中滚动多个回收器视图。(如何使其平滑)

Java 在活动中滚动多个回收器视图。(如何使其平滑),java,android,android-recyclerview,scrollview,Java,Android,Android Recyclerview,Scrollview,我的活动中有两个recyclerviews,第一个是水平滚动的,第二个是垂直滚动的。(下面给出了XML代码) 但是滚动并不平滑 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ll1" android:layout_width="match_parent" android:layout_height="match_parent"

我的活动中有两个recyclerviews,第一个是水平滚动的,第二个是垂直滚动的。(下面给出了XML代码) 但是滚动并不平滑

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ll1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#eeeeee"
    android:clickable="true"
    >
    <ProgressBar
        android:id="@+id/progressBarCircularIndetermininatesearch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminateTintMode="src_atop"
        android:indeterminateTint="#f44336"
        android:layout_centerInParent="true"/>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/progressbacklin"
        android:scrollbars="none"
        >
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    <android.support.v7.widget.RecyclerView
        android:id="@+id/videolist"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="2dp"
        android:layout_marginRight="2dp"
        android:layout_alignParentTop="true"
        android:scrollbars="none"
        />


    <android.support.v7.widget.RecyclerView
        android:id="@+id/list"
        android:layout_below="@+id/videolist"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="2dp"
        android:layout_marginRight="2dp"
        android:scrollbars="none"
        />
        </RelativeLayout>
</ScrollView>
    <LinearLayout
        android:id="@+id/progressbacklin"
        android:layout_above="@+id/adViewsearch"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_marginBottom="90dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/white"
        android:gravity="center"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        >
        <ProgressBar
            android:id="@+id/progressBarCircularIndetermininate"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:indeterminateTintMode="src_atop"
            android:indeterminateTint="#f44336"
            android:layout_centerInParent="true"/>
    </LinearLayout>
    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adViewsearch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/banner_ad_unit_id" />

</RelativeLayout>
对于两个回收器视图


有没有办法通过平滑滚动来实现这一点?

ScrollView
更改为
NestedScrollView


为了实现这一点,您需要在
NestedScrollView
中设置高度
wrap\u content
RecyclerView
,并且需要从代码中将
RecyclerView.setNestedScrollingEnabled(false)
设置为
NestedScrollView


为了实现这一点,您需要在
NestedScrollView
内部设置高度
wrap\u内容
RecyclerView
,并且需要从code中设置
RecyclerView.setNestedScrollingEnabled(false)

我是如何通过使用一个回收器视图而不是两个并设置另一个来解决这个问题的(有问题的第一个回收者视图)回收者视图作为其第一项。
现在它运行完美,滚动顺畅。

我解决这个问题的方法是使用一个而不是两个回收器视图,并将另一个(第一个有问题的回收器视图)回收器视图设置为第一项。
现在,它工作完美,滚动顺畅。

虽然此代码可能会回答问题,但提供有关如何和/或为什么解决问题的附加信息将提高答案的长期价值。请记住,您是在将来为读者回答问题,而不仅仅是现在提问的人!请您的答案添加解释,并指出适用的限制和假设。虽然此代码可能会回答问题,但提供有关如何和/或为什么解决问题的附加说明将提高答案的长期价值。请记住,您是在将来为读者回答问题,而不仅仅是现在问问题的人!请添加您的答案解释,并说明适用的限制和假设。
setNestedScrollingEnabled(false);