首页 > 代码库 > shimmer使用方法(文本闪烁)

shimmer使用方法(文本闪烁)

1.github下载  https://github.com/facebook/shimmer-android

2.copy ShimmerFrameLayout.java 连同包名到java目录

3.copy attrs.xml 到 values 目录

4.

<com.facebook.shimmer.ShimmerFrameLayout
        android:id="@+id/shimmer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!Hello World!Hello World!Hello World!Hello World!" />
</com.facebook.shimmer.ShimmerFrameLayout>

5.

ShimmerFrameLayout shimmar = (ShimmerFrameLayout) findViewById(R.id.shimmer);
shimmar.startShimmerAnimation();

注:各种style

        mShimmerViewContainer.setDuration(5000);
        mShimmerViewContainer.setRepeatMode(ObjectAnimator.REVERSE);

        mShimmerViewContainer.setBaseAlpha(0.1f);
        mShimmerViewContainer.setDropoff(0.1f);
        mShimmerViewContainer.setTilt(0);

        mShimmerViewContainer.setAngle(ShimmerFrameLayout.MaskAngle.CW_90);

        mShimmerViewContainer.setBaseAlpha(0);
        mShimmerViewContainer.setDuration(2000);
        mShimmerViewContainer.setDropoff(0.1f);
        mShimmerViewContainer.setIntensity(0.35f);
        mShimmerViewContainer.setMaskShape(ShimmerFrameLayout.MaskShape.RADIAL);

 

 

 

  

shimmer使用方法(文本闪烁)