滚动到全视图与里面的回收者视图

Par*_*ria 7 android android-scrollview android-recyclerview

我想建立一个屏幕,我在顶部和下面有一个布局,我有一个像这样的回收站视图:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    tools:context="com.app.InstHomeDir.Fragments.PendingDocument"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/main_bg"
   >

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginBottom="15dp"
        >

    <android.support.v7.widget.CardView

        android:background="@color/white"
        app:cardElevation="2dp"
        app:cardCornerRadius="2dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <com.app.InstHomeDir.Util.Roboto_Edit_Text_Bold
             android:textColor="@color/bl2d2d2d"
             android:padding="5dp"
            android:text="DOCUMENT LIST"
                android:textSize="20sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
            <com.app.InstHomeDir.Util.Roboto_EditText
             android:padding="5dp"
             android:textColor="#6f6f6f"
            android:layout_marginTop="5dp"
            android:layout_width="wrap_content"
                android:textSize="12sp"
            android:text="@string/Pending_Doc"
            android:layout_height="wrap_content"/>
        </LinearLayout>


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


    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_penddoc"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_anchor="@id/toolbar_layout"
        app:layout_anchorGravity="bottom|center"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >

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


    </LinearLayout>



</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

现在我想给整个视图滚动视图,但是当我这样做时,屏幕的滚动并不顺畅,因为屏幕上有两个滚动,我该如何解决这个问题?谁能帮我?

Par*_*ria 8

添加页眉和页脚是一种方式,但我发现更容易看到它.将整个视图放在滚动视图中.现在这将使滚动有点慢,它看起来不会很好,所以要克服这个使用此代码:

  layoutManager = new LinearLayoutManager(getActivity()){
        @Override
        public boolean canScrollVertically() {
            return false;
        }
    };
Run Code Online (Sandbox Code Playgroud)

现在问题是当我在滚动视图中添加整个视图时,同一视图中有2个滚动.所以我们面临这个问题.现在,如果我们删除其中一个的滚动属性,那么它再次顺利运行.因此,我们删除了回收器视图的滚动属性,因为它是孩子.

奇迹般有效.

  • 我试图这样做,我的回收站视图停止显示所有项目。仅第1页上可见的那些可见。 (3认同)