【问题标题】:Android RecyclerView with progress indicator and animation带有进度指示器和动画的 Android RecyclerView
【发布时间】:2015-12-26 20:41:54
【问题描述】:

在 Material Design 指南中,有一种一次性加载和显示所有内容的模式。

Link

如何使用 RecyclerView 实现?

【问题讨论】:

    标签: android android-animation material-design android-recyclerview


    【解决方案1】:

    您可以通过切换进度条和回收器视图的可见性来简单地做到这一点。

    在你的布局中,

    <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>
    

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

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

    希望对你有用。

    【讨论】:

    • 如何为 recyclerview 项目做同样的动画?
    • 嗨,@MotassemJalal,您只需要做同样的事情,但现在使用适配器行。
    猜你喜欢
    • 2018-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多