使用方法;
配置工程
首先,我们在GitHub上将该项目clone到本地;
github.com/facebook/sh…
接下来我们在Android studio中导入所需要的module, 即shimmer-android;
最后,需要配置一下下自己的gradle,引用该module:
dependencies {
compile project(‘:shimmer-android’)
}xml布局文件,将需要加入特效的控件用ShimmerFrameLayout包裹
<!--会员等级-->
<com.facebook.shimmer.ShimmerFrameLayout
android:id="@+id/shimmerContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/btn_huiyuanlevel"
android:layout_width="60dp"
android:layout_height="18dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="@id/huiyan_name"
android:background="@drawable/qingtonghuiyuanbg"
android:gravity="center"
android:text="青铜会员"
android:textColor="#648728"
android:textSize="12sp" />
</com.facebook.shimmer.ShimmerFrameLayout>
java代码中设置启动发光字配置属性
ShimmerFrameLayout shimmerFrameLayout = (ShimmerFrameLayout) findViewById(R.id.shimmerContent);
shimmerFrameLayout.setRepeatMode(ObjectAnimator.REVERSE);
shimmerFrameLayout.setDuration(1000);
shimmerFrameLayout.setDropoff(0.4f);//设置光的宽度
shimmerFrameLayout.setBaseAlpha((float) 0.9);//设置没有光照的地方的透明度
// shimmerFrameLayout.setIntensity(6);//设置光的强度
//设置光的形状,线性ShimmerFrameLayout.MaskShape.LINEAR(默认),ShimmerFrameLayout.MaskShape.RADIAL圆形
shimmerFrameLayout.setMaskShape(ShimmerFrameLayout.MaskShape.RADIAL);
shimmerFrameLayout.startShimmerAnimation();