欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Shimmer-Android使用FrameLayout给视图添加微光效果

程序员文章站 2022-03-23 08:03:15
1、shimmer-android是Facebook出品的给任意视图添加微光效果的第三方库。2、配置dependencies { implementation 'com.facebook.shimmer:shimmer:0.4.0' } 3、基本使用

1、shimmer-android是Facebook出品的给任意视图添加微光效果的第三方库。

2、配置

dependencies {
   implementation 'com.facebook.shimmer:shimmer:0.4.0'
 } 

3、基本使用

 <com.facebook.shimmer.ShimmerFrameLayout
        android:id="@+id/shimmer_view_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        <!--我们希望起微光效果的视图-->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="我的微信公众号:自学者" />
            
    </com.facebook.shimmer.ShimmerFrameLayout> 

4、在Java文件中开启微光动画

ShimmerFrameLayout container = (ShimmerFrameLayout) findViewById(R.id.shimmer_view_container);
        //开启微光动画
        container.startShimmerAnimation(); 

5、方法参数

setAutoStart():设置是否自动启动微光动画
setBaseAlpha:设置基视图的背景颜色
setDuration():从一个布局到另一个布局亮点需要时间。
setRepeatCount():设置当前动画重复的次数
setRepeatDelay():延迟多长时间重复当前动画
setRepeatMode():设置动画重复的模式
setMaskShape():设置当前高亮面具的形状
setAngle():设置当前高亮面具的角度 

6、GitHub:

https://github.com/facebook/shimmer-android

本文地址:https://blog.csdn.net/weixin_44720673/article/details/107706704