Android 滚动RecyclerView时滚动顶部内容
我正在开发一个原生android应用程序,我想做一些事情,但不知道如何做。我在我的recyclerview上面有一个可以滚动的布局,我希望它在我滚动recyclerview或布局本身时上升,直到recyclerview(高度为包裹内容)完全占据屏幕 我试图做到以下几点:Android 滚动RecyclerView时滚动顶部内容,android,android-recyclerview,Android,Android Recyclerview,我正在开发一个原生android应用程序,我想做一些事情,但不知道如何做。我在我的recyclerview上面有一个可以滚动的布局,我希望它在我滚动recyclerview或布局本身时上升,直到recyclerview(高度为包裹内容)完全占据屏幕 我试图做到以下几点: 在NestedScrollView上添加上述内容并添加 app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior” 回收视图 这不起作用,recyc
- 在NestedScrollView上添加上述内容并添加
回收视图 这不起作用,recyclerview不会扩展到上面的布局。每一个都有它的初始高度,并在该区域内滚动app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”
- 在NestedScrollView中添加了所有内容,包括recyclerview。这几乎起到了作用,尤其是在添加了
之后,但这打破了RecyclerView模式,所有的RecyclerView内容都将在开始时加载,而不是在我滚动时加载setNestedScrollingEnable(true)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:orientation="vertical"
android:gravity="center"
android:paddingBottom="@dimen/activity_vertical_margin"
>
<com.facebook.drawee.view.SimpleDraweeView
android:id="@id/profilePicture"
android:layout_width="@dimen/profileCircleHeight"
android:layout_height="@dimen/profileCircleHeight"
fresco:roundingBorderWidth="1dp"
fresco:roundingBorderColor="@color/profileCircleBorder"
fresco:roundAsCircle="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/userName"
/>
<TextView
android:text="@string/friends"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/userFriends"
android:background="@color/cardColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>