添加项目时,RecyclerView会滚动到顶部

时间:2017-03-15 13:13:15

标签: android android-recyclerview

我有一个RecyclerView并且我使用顶部填充,而最初它是在我从网络获取数据时显示的,我将它们添加到适配器,RecyclerView滚动到顶部,填充是改为零。

在添加新项目时,有没有办法保持顶部填充?

Xml布局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:background="@color/main_bg" android:clickable="true">

<FrameLayout
    android:layout_width="match_parent" android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/iv_profile_cover"
        android:scaleType="fitXY"
        android:layout_width="match_parent" android:layout_height="@dimen/profile_cover_height"
        android:contentDescription="Cover image" />

    <ImageView
        android:src="@color/light_grey_with_alpha"
        android:contentDescription="Gray Overlay"
        android:layout_width="match_parent" android:layout_height="@dimen/profile_cover_height" />

</FrameLayout>

<android.support.v7.widget.RecyclerView
    android:id="@+id/rv_profile_photo_list"
    android:clipToPadding="false" android:clipChildren="false" android:paddingTop="@dimen/profile_content_height"
    android:layout_marginTop="?attr/actionBarSize"
    android:layout_marginLeft="16dp" android:layout_marginRight="16dp"
    android:layout_width="match_parent" android:layout_height="wrap_content" />

</FrameLayout>

0 个答案:

没有答案
相关问题