带有进度指示器和动画的Android RecyclerView

Ale*_*sky 9 android android-animation material-design android-recyclerview

在Material Design指南中,有一种模式可以一次加载和显示所有内容.

链接

如何使用RecyclerView实现它?

Ark*_*ung 18

您可以通过切换进度条和recyclerview的可见性来实现.

在你的布局中,

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
      <ProgressBar
            android:id="@+id/progress_bar"
            style="?android:progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone"
            />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

根据上面的布局,在您的数据准备好之前,屏幕上会显示进度条.数据准备好后,您可以切换这样的可见性.

mRecyclerAdapter.setData(mData); // need to implement setter method for data in adapter
mRecyclerAdapter.notifyDataSetChanged();
mRecyclerView.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.GONE);
Run Code Online (Sandbox Code Playgroud)

希望它对你有用.

  • 如何为recyclerview项目执行相同的动画? (12认同)