
微光效果.gif
导入依赖
implementation 'com.facebook.shimmer:shimmer:0.5.0'
简单使用
<com.facebook.shimmer.ShimmerFrameLayout
android:id="@+id/shimmer_view_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
...(your complex view here)...
</com.facebook.shimmer.ShimmerFrameLayout>
代码启动(auto-start
为 false)
ShimmerFrameLayout container =
(ShimmerFrameLayout) findViewById(R.id.shimmer_view_container);
container.startShimmer();
代码属性设置(例子如下,使用完成后,还原按钮效果)
ShimmerFrameLayout container =
(ShimmerFrameLayout) findViewById(R.id.shimmer_view_container);
//开始
container.startShimmer();
//去掉默认背光效果(更多API请产考顶部官方API文档)
shimmer = new Shimmer.AlphaHighlightBuilder()
.setBaseAlpha(1)
.build();
//暂停
container.stopShimmer();
container.setShimmer(shimmer);
网友评论