recyclerview无法正确滚动

时间:2018-04-14 19:00:38

标签: android xml android-recyclerview

我的recyclerView没有正确滚动,我试图制作像Instagram个人资料一样的页面,所以我放置了折叠工具栏,swiperefreshLayout,nestedScrollView和recylerview。在这个活动中,我在回收一下这个人的一些信息,我希望有人能理解我。

Here is a a screenshot of my problem

我想让所有的布局像一块一样是有些人知道的方式!

这是xml

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/coordinate_layout">
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/collapsing_toolbar"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:contentScrim="@color/colorPrimary"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginEnd="64dp"
            >

            <!--<ImageView
                android:id="@+id/collapsing_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax"
                android:fitsSystemWindows="true"/>-->
            <android.support.v7.widget.Toolbar
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:id="@+id/toolbar_layout"
                android:layout_gravity="top"
                app:layout_collapseMode="parallax"
                app:popupTheme="@style/AppTheme.PopupOverlay"
                >
                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="?attr/actionBarSize"
                    android:dividerPadding="8dp"
                    android:orientation="horizontal"
                    android:showDividers="end">

                    <TextView
                        android:id="@+id/toolbar_title"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
                        android:padding="8dp"
                        android:paddingLeft="16dp"
                        android:paddingRight="16dp"
                        android:text="Upload Item"
                        android:textColor="@color/white"
                        android:gravity="center_vertical"
                        />

                    <TextView
                        android:id="@+id/toolbar_save"
                        style="@style/TextAppearance.Widget.AppCompat.Toolbar.Subtitle"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="?attr/selectableItemBackground"
                        android:drawablePadding="8dp"
                        android:drawableRight="@drawable/done"
                        android:gravity="center_vertical"
                        android:paddingLeft="16dp"
                        android:paddingRight="16dp"
                        android:textAllCaps="true"
                        android:layout_alignParentTop="true"
                        android:layout_alignParentStart="true" />

                </RelativeLayout>
            </android.support.v7.widget.Toolbar>

        </android.support.design.widget.CollapsingToolbarLayout>


    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.SwipeRefreshLayout
        android:layout_width="match_parent"
        android:id="@+id/swipe_to_refresh"
        android:layout_height="match_parent"
        android:layout_below="@+id/coordinate_layout"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">

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

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/relative1">
                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="200dp"
                        android:src="@drawable/shoes"
                        android:id="@+id/profile_imagee"
                        />
                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="200dp"
                        android:src="@drawable/shoes"
                        android:id="@+id/profile_imagee1"
                        android:layout_below="@+id/profile_imagee"
                        />
                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="200dp"
                        android:src="@drawable/shoes"
                        android:id="@+id/profile_imagee2"
                        android:layout_below="@+id/profile_imagee1"
                        />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="change profile"
                        android:layout_below="@+id/profile_imagee2"/>
                </RelativeLayout>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_below="@+id/relative1"
                    >

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


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



                    <android.support.v4.widget.SwipeRefreshLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">


                    </android.support.v4.widget.SwipeRefreshLayout>

                </RelativeLayout>


            </RelativeLayout>



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



    </android.support.v4.widget.SwipeRefreshLayout>



</android.support.design.widget.CoordinatorLayout>


<!--<ImageView
    android:id="@+id/profileImage"
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:src="@drawable/background"/>-->

1 个答案:

答案 0 :(得分:0)

尝试设置ViewCompat.setNestedScrollingEnabled(recycler_view, false)