簡體   English   中英

Android多個水平回收站視圖一起滾動

[英]Android multiple horizontal recycler-view scroll together

你好,我有包含兩個這樣的回收站視圖的android應用程序

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

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerViewMainFragment"
            android:layout_width="match_parent"

            android:layout_height="wrap_content" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerResults"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

如何使這些回收商一起滾動?

將此代碼放入“ 滾動視圖”中 ,它將自動滾動。 您也可以將多個回收站視圖放入線性布局中,它將完美地工作。

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/hsv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

        <LinearLayout
            android:id="@+id/innerLay"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rv_1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rv_2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>

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

https://stackoverflow.com/a/43645502/7522720這將是有幫助的

運用

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); if (isLastItemDisplaying(recyclerView)) { //Calling the method getdata again getData(); } } });

將第一個recyclerview xy設置為第二個recyclerview,以滾動第一個。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM