ShimmerRecyclerView

  • 进度条 (ProgressBar)
  • ★★★★★
  • 2017-01-08 21:55
  • 858 kb
  • Android Studio

介绍:

一个可以在加载数据的时候显示闪烁(Shimmer)的RecyclerView。

运行效果:

使用说明:

属性

XML 属性Java 方法解释
app:demo_child_countsetDemoChildCount(int)Integer value that sets the number of demo views should be present in shimmer adapter
app:demo_layoutsetDemoLayoutReference(int)Layout reference to your demo view. Define your my_demo_view.xml and refer the layout reference here.
app:demo_layout_manager_typesetDemoLayoutManager(LayoutManagerType)Layout manager of demo view. Can be one among linear_veritical or linear_horizontal or grid.

xml:

<com.cooltechworks.views.shimmer.ShimmerRecyclerView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/shimmer_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:demo_child_count="10"
        app:demo_grid_child_count="2"
        app:demo_layout="@layout/layout_demo_grid"
        app:demo_layout_manager_type="grid"
        />

where @layout/layout_demo_grid refers to your sample layout that should be shown during loading spinner. Now on your activity onCreate, initialize the shimmer as below:

ShimmerRecyclerView shimmerRecycler = (ShimmerRecyclerView) findViewById(R.id.shimmer_recycler_view);
shimmerRecycler.showShimmerAdapter();

Adding to your project

  • Add the following configuration in your build.gradle file.

repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.sharish:ShimmerRecyclerView:v1.0'
}