码迷,mamicode.com
首页 > 移动开发 > 详细

安卓开发打造闪光控件效果

时间:2018-03-12 18:34:16      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:jpg   启动   clone   gradle   name   avr   pretty   sso   公众   

 

使用方法;
配置工程
首先,我们在GitHub上将该项目clone到本地;
https://github.com/facebook/shimmer-android
接下来我们在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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

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();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

安卓开发打造闪光控件效果

标签:jpg   启动   clone   gradle   name   avr   pretty   sso   公众   

原文地址:https://www.cnblogs.com/totoo/p/shimmerFrameLayout.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!