简体   繁体   English

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

[英]Scrolling of multiple recycler view in an activity. (how to make it smooth)

I have 2 recyclerviews in my activity 1st one is horizontally scrollable and the 2nd one is vertically scrollable. 我的活动中有2个recyclerviews,第一个可水平滚动,第二个可垂直滚动。 (XML code given below) But the scrolling is not smooth. (下面给出了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>

i use 我用

setNestedScrollingEnabled(false); 

for both recycler view. 对于两个回收者视图。

Any ideas to implement this with a smooth scrolling? 有什么想法可以实现平滑滚动吗?

Change ScrollView to NestedScrollView . ScrollView更改为NestedScrollView

In order this to work, you need to have RecyclerView with height wrap_content inside NestedScrollView and you need to set recyclerView.setNestedScrollingEnabled(false) from code. 为了使其正常工作,您需要在NestedScrollView具有高度为wrap_content RecyclerView ,并且需要从代码中设置recyclerView.setNestedScrollingEnabled(false)

How i solved this problem is by using a single Recycler view instead of two and setting up the other (1st recycler view in question) recycler view as first item of it. 我如何解决此问题的方法是使用单个“回收者”视图而不是两个,并将另一个(有问题的第一个回收者视图)设置为它的第一项。 Now it works perfect and scrolling smoothly. 现在,它可以完美运行并且可以平滑滚动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用偏移量回收器视图使自动平滑滚动? - How to make auto smooth scroll with offset Recycler View? 如何在不重新创建(重新启动)活动的情况下更新 RecyclerView。 我使用 SQLite 数据库将数据存储和检索到 Recycler 视图 - How to update RecyclerView without recreating (restarting) the activity. I use SQLite Database to store and retrieve data to the Recycler view 如何从其他活动更改视图。 - How to change a view from a different activity. 如何从Recycler View onClick缓存WebView活动的多个URL - How to cache multiple URLs for a WebView Activity from Recycler View onClick 如何在Horizenatl滚动中使用Recycler视图 - How to use Recycler view in Horizenatl Scrolling 如何在Activity中初始化接口。 - How to initialize interface in Activity. 我无法从一个卡片视图活动中导航到多个活动。 我可以导航到“仅1个” - I cannot navigate to multiple activities from a single Card View Activity. I can navigate to Only 1 Swing:如何让JFrame滚动流畅? - Swing: How to make JFrame scrolling smooth? 碎片活动的回收者视图 - Recycler View on Fragment Activity RecyclerView Item Count On TextView 仅在重新进入活动时更新。 如何让它实时更新 - RecyclerView Item Count On TextView Only Updates When Re-entering the activity. How To Make It Update In RealTime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM