您可以使用Facebook’s Shimmer Library
如何使用
将 Shimmer 依赖项添加到您build.gradle
的项目并重建项目。
dependencies {
// Shimmer
implementation 'com.facebook.shimmer:shimmer:0.1.0@aar'
}
添加你的 layout.xml 文件
<com.facebook.shimmer.ShimmerFrameLayout
android:id=“@+id/shimmer_view_container”
android:layout_width=“wrap_content”
android:layout_height="wrap_content"
shimmer:duration="5000" // Number of milliseconds to animate one ‘sweep’
>
// your complex view here
</com.facebook.shimmer.ShimmerFrameLayout>
现在在你的活动中
ShimmerFrameLayout container =
(ShimmerFrameLayout) findViewById(R.id.shimmer_view_container);
container.startShimmerAnimation();
这是它的好文章Android Content Placeholder Animation like Facebook using Shimmer