当放置在NestedScrollview中时,Recyclerview失去边缘效果

时间:2018-10-04 13:13:08

标签: android android-recyclerview android-nestedscrollview

我正在尝试将recyclerview放置在嵌套滚动视图中。以下是我的布局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/nestedscrollview">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            >
            <fragment
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:name="com.example.nestedscrollviewexample.ItemFragment"
                android:layout_marginTop="84dp"
                android:id="@+id/itemfragment"/>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>


</FrameLayout>

该片段包含一个简单的Recylerview。

我注意到的是,如果recyclerview在NestedScrollView之外,那么它将保留其边缘效果。但是,当我将回收站视图放在nestedscrollview内时,边缘效果消失了。

相反,当我添加以下行时-

ViewCompat.setNestedScrollingEnabled(recyclerView, false);

我注意到边缘效果是可见的,但仅适用于嵌套滚动视图的边缘。如何在回收者视图中保留边缘效果?

为了更清晰起见,我共享2张图片-

  1. 首先是Recyclerview边缘效果,然后再将其添加到嵌套滚动视图中。 [Recyclerview edge effect before adding it to nested scroll view]

  2. 以下是当我们将回收站视图添加到嵌套滚动视图时- enter image description here

我希望将recyclerview放在嵌套的scrollview中,并同时保持其边缘效果。有可能吗?

0 个答案:

没有答案