简体   繁体   English

带有循环内Recyclerview的Scrollview滚动到底部(不间断)

[英]Scrollview with Recyclerview inside loops scroll to the bottom (nonstop)

I'm having a weird issue here, the normal issue that the ScrollView only scrolls once, but in my case, it keeps scrolling and scrolling to the bottom. 我在这里遇到一个奇怪的问题,即ScrollView仅滚动一次的正常问题,但就我而言,它一直在滚动并滚动到底部。

XML: XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>


<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="15dp">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/search"
        android:src="@drawable/ic_search"
        android:layout_gravity="end"/>

</FrameLayout>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/scrollview"
    android:scrollbars="none">

    <LinearLayout
        android:layout_width="match_parent"
        android:focusableInTouchMode="true"
        android:layout_height="wrap_content"
        android:descendantFocusability="blocksDescendants"
        android:orientation="vertical">

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

            <com.daimajia.slider.library.SliderLayout
                android:id="@+id/slider"
                android:layout_width="match_parent"
                android:layout_height="@dimen/slider_height"
                />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/home_rv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scrollbars="none"
                android:layout_marginTop="@dimen/slider_rv_margin"
                />

        </RelativeLayout>


    </LinearLayout>


</ScrollView>
</RelativeLayout>

Code: 码:

    mScrollView = (ScrollView) mView.findViewById(R.id.scrollview);
    mRecyclerView.setNestedScrollingEnabled(false);
    mRecyclerView.addOnScrollListener(new EndlessRecyclerViewScrollListener(mGridLayout) {
        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
            Log.i("Scroller","Scrolling: Page " + page + " - Total: " + totalItemsCount);
            mCurrentPage = mCurrentPage + 1;
            GetArticles(false);
        }
    });

The log keeps getting called, for example: 日志不断被调用,例如:

     10-06 15:55:33.027 794-794/com.testapp I/Scroller: Scrolling: Page 4 - Total: 16
     10-06 15:55:33.639 794-794/com.testapp I/Scroller: Scrolling: Page 5 - Total: 20
     10-06 15:55:34.264 794-794/com.testapp I/Scroller: Scrolling: Page 6 - Total: 24
     10-06 15:55:34.895 794-794/com.testapp I/Scroller: Scrolling: Page 7 - Total: 28
     10-06 15:55:35.573 794-794/com.testapp I/Scroller: Scrolling: Page 8 - Total: 32
     10-06 15:55:36.311 794-794/com.testapp I/Scroller: Scrolling: Page 9 - Total: 36
     10-06 15:55:36.923 794-794/com.testapp I/Scroller: Scrolling: Page 10 - Total: 40
     10-06 15:55:37.513 794-794/com.testapp I/Scroller: Scrolling: Page 11 - Total: 44

What is that EndlessRecyclerViewScrollListener? 那EndlessRecyclerViewScrollListener是什么? It should be OnScrollListener right? 应该是OnScrollListener吧? It may be causing the problem. 这可能是导致问题的原因。

使用<android.support.v4.widget.NestedScrollView>而不是<ScrollView>

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM